Re: groovy regex match group

2018-03-14 Thread mg
ps: if(matcher) invokes Groovy truth (asBoolean()), which calls find() on the 
matcher
 Ursprüngliche Nachricht Von: Vladimir Frelikh 
<e28...@gmail.com> Datum: 14.03.18  12:17  (GMT+01:00) An: 
users@groovy.apache.org 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!



groovy regex match group

2018-03-14 Thread Vladimir Frelikh
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!