Showing posts with label match operator. Show all posts
Showing posts with label match operator. Show all posts

Monday, 14 January 2019

Groovy: Match operator (==~)


Match (==~) operator return true, if given text matches to the pattern, else false.

HelloWorld.groovy

def text = "aaaab"
boolean isMatched = text ==~ /a*b/  

println "Is aaaab matched to the pattern a*b " + isMatched

Output
Is aaaab matched to the pattern a*b true


Previous                                                 Next                                                 Home