I'm struggling to find the correct RegEx for this problem:
I want to search a string for a value. If true, the result should be an emty string, otherwise the whole string.
Example
"We have apples, oranges, and peas"
Check for "apples" -> "
Check for "tomato" -> "We have apples, oranges, and peas"
I have to solve it using a standard RegEx statement. Since it is the only way I can modify the original string in the application.
Basically what I want to do is:
s="We have apples, oranges, and peas"
w="tomato"
IF instr(s,w)>0 then result="" else result=s
The problem is that the only way I can modify the string is by a regex syntax
I believe I have solved it by myself. Have no clue why it works :)
(?(?=.*apples)|.*)|.*
returns nothing as I want
(?(?=.*banana)|.*)|.*
returns We have apples, oranges, and peas
The following regex also works
^((?!apples).)*$