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

No comments:

Post a Comment