The trick is to do the negative assertion at every point in the expression, and you need to anchor both the start and the end, something like this should do the trick (it will match everything except red
,green
and yellow
):
/^(?:(?!red|green|blue).)*$/