How to negate the Groovy Match Operator?

AFAIK, there is no negated regular expression match operator in Groovy.

So – as already mentioned by cfrick – it seems that the best answer is to negate the whole expression:

println !('bb' ==~ /^a.*/)

Another solution is to invert the regular expression, but it seems to me to be less readable:

How can I invert a regular expression in JavaScript?

Leave a Comment