views:

989

answers:

3

This should be an easy one for the Regex experts out there... :)

I want to match any string that does not contain the string "DontMatchThis".

What's the regex?

+5  A: 

try this:

^(?!.*DontMatchThis).*$
Kamarey
Bullseye! Thanks!
Shaul
A: 

I have similar problem and my pattern match only last entry but i want more :) Idea is capturing xml comments:

<!--(?!.*(<!--)).*-->
MisterJBee
MisterJBee, if you have a question, please create your own instead of posting it in here (as an answer). Thanks.
Bart Kiers
-1 - Pls ask your own question. Nobody will answer it if you're posting as an answer...
Shaul
A: 

Just use !:

! new Regex("DontMatchThis").IsMatch(input)

Christoffer Hammarström