I am trying to create a "simple" regex to match any string except a specific string in middle. Lets assume that the specific string is apple
, Here are results that I expect:
apple -> false
foo-apple -> false
foo-apple-bar -> false
empty-string -> true
foo -> true
I tried:
^(?!apple)$
^(?!apple$)
^.*(?!apple).*$
^(.*(?!apple).*)$
but none of them worked as I expected. This question looks similar but the accepted answer is not working.