foo, bar, tag
I want my regex to match if the sentence doesn't contain all three words together above.
foo bar goal
But if the words are all together, it shouldn't match.
foo bar tag
I have tried this regex in Python but couldn't make it work.
^(?!.*(foo)).*(?!.*(bar)).*(?!.*(tag)).*$
Any ideas? Thanks.
You can nest positive lookheads with negative lookahead like this:
^(?!(?=.*foo)(?=.*bar)(?=.*tag)).*$
Here are the test cases