Example:
Suppose in the following example I want to match strings that do not contain the word “NOOOT”.
Example A: This shirt is NOOOT black.
Example B: This shirt is black.
I want something a little bit like the like the non-matching character class (e.g. [^abc]), but for whole strings:
.*?(^NOOOT).*?
Does such a creature exist?
Explanation:
^start of string(?!NOOOT).assert that it’s not possible to matchNOOOTat the current position, then match any character.(?: ...)*do this any number of times until…$end of string.