groovy正则表达式入门

心情不是很好,直接贴代码吧:

def s1='abc'
def s2='a.c'
def s3='fo*d'
def s4='fod'
def s5='fooood'
def s6= 'helloworld'

println s1 ==~ s2 //true
println s4 ==~ s3 //true
println s3 ==~ s4 //false
println s4 ==~ s3 //true
println s6 ==~ /helloworlddd?/ //false
println s1 ==~ 'a[a,b]c' // true
println s1 ==~ 'a[b]{1}c'//true
println 'abbbbc' ==~ 'a[b]{1,3}c'//true

你可能感兴趣的:(groovy)