I need a negative lookahead expression, but I can’t make it work 🙁 I hope someone can help me. I need an expression which is true until the sample does not contain 2 words anywhere in the sample. For example the 2 words pie donuts:
i sure like eating pie, but i love donuts very much
---> false
i sure like eating but i love donuts very much
---> true
i sure like eating pie, but i love hamburger very much
---> true
i sure like eating donuts, but i love pie very much
---> false
i sure like eating piedonuts very much
---> false
I have tried it in many forms, but it does not work.
You could do this with two positive lookaheads that are nested inside a negative one (all starting from the beginning of your string):
So the inner lookaheads require to match both words. If they do the contents of the negative lookahead will match, so the lookahead itself will cause the pattern to fail.
If you can have line breaks in your input, make sure to use the
sordotalloption (otherwise,.does not match line breaks).