Came across a situation today were I need to inverse match on a string. In other words I want to match anything that is not xyz.
Here is how to do it using negative look-ahead:
^((?!xyz).+)$
Alternatively you can use negative look-behind:
^(.+(?<!xyz))$
2 Comments
Hi Marco,
Thanks for this very easy and off course effective regex.
Regards,
shivang
Fantastic, thanks for this!