How can I write a regular expression that will not match if a string contains a particular substring

Posted by Iain Fraser on Stack Overflow See other posts from Stack Overflow or by Iain Fraser
Published on 2010-03-19T07:35:48Z Indexed on 2010/03/19 7:41 UTC
Read the original article Hit count: 274

Filed under:
|
|

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?

© Stack Overflow or respective owner

Related posts about regex

Related posts about string-manipulation