Pattern operator (~) provides simple way to create a java.util.regex.Pattern
object.
HelloWorld.groovy
def pattern = ~'a*b' def matcher = pattern.matcher("aaaab") matcher.matches() println "I found the text " + matcher.group() println "Starting at index " + matcher.start() println "Ending at index " + matcher.end()
Output
I found the text aaaab Starting at index 0 Ending at index 5
No comments:
Post a Comment