Shaul Behr Shaul Behr - 3 months ago 16
C# Question

C# Regex to match a string that doesn't contain a certain string?

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

What's the regex?

Answer

try this:

^(?!.*DontMatchThis).*$