Skip to content

Instantly share code, notes, and snippets.

@AndersDJohnson
Last active June 5, 2019 13:35
Show Gist options
  • Save AndersDJohnson/5905129 to your computer and use it in GitHub Desktop.
Save AndersDJohnson/5905129 to your computer and use it in GitHub Desktop.
groovy inverse regex operator?
// as expected:
println ("string" ==~ "str.*")
// => true
// compiles, but not as expected:
println ("string" !=~ "str.*")
// => true
// does not compile:
//println ("string" !==~ "str.*")
// this is the solution:
println (! ("string" ==~ "^str.*"))
// => true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment