groovy-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Vladimir Frelikh <e28...@gmail.com>
Subject groovy regex match group
Date Wed, 14 Mar 2018 11:17:36 GMT
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!

Mime
View raw message