I would like to negate a set of words using java regex.
Say, I want to negate cvs
, svn
, nvs
, mvc
. I wrote a regex which is ^[(svn|cvs|nvs|mvc)]
.
Some how that seems not to be working.
Try this:
^(?!.*(svn|cvs|nvs|mvc)).*$
this will match text if it doesn't contain one of svn, cvs, nvs or mvc.
This is a similar question: C# Regex to match a string that doesn't contain a certain string?