ps: if(matcher) invokes Groovy truth (asBoolean()), which calls find() on the
matcher
-------- Ursprüngliche Nachricht --------Von: Vladimir Frelikh
<[email protected]> Datum: 14.03.18 12:17 (GMT+01:00) An:
[email protected] Betreff: groovy regex match group
Hello,could someone help with the following code:
text = 'test'def matcher = text =~ /(test)/print matcher.group(1)
getting error:java.lang.IllegalStateException: No match found
but the following code works as expected:
text = 'test'def matcher = text =~ /(test)/if (matcher ) { print
matcher.group(1)}
Thanks!