Skip to end of metadata
Go to start of metadata
You are viewing an old version of this page. View the current version. Compare with Current ·  View Page History

Groovy supports regular expressions natively using the ~"..." expression. Plus Groovy supports the =~ (create Matcher) and ==~ (matches regex) operators. e.g.

Error rendering macro 'code' : Invalid value specified for parameter lang

Since a Matcher coerces to a boolean by calling its find method, the =~ operator is consistent with the simple use of Perl's =~ operator, when it appears as a predicate (in 'if', 'while', etc.). The "stricter-looking" ==~ operator requires an exact match of the whole subject string.

(It would be nice to supply other Perl amenities, such as !~ and in-place edits of string variables. This is a job for someone familiar with the range of use cases, and their expressions in terms of Java Matchers. – John Rose.)

Labels
  • None