examples/groovy/match_number.groovy

text = 'Some 42 number #12 more'
def ma = (text =~ /\d+/)
println ma              // java.util.regex.Matcher[pattern=\d+ region=0,23 lastmatch=]
println ma[0]           // 42

def mb = (text =~ /#\d+/)
println mb              // java.util.regex.Matcher[pattern=#\d+ region=0,23 lastmatch=]
println mb[0]           //  #12

def mc = (text =~ /#(\d+)/)
println mc[0]          // [#12, 12]
println mc[0][0]       // #12
println mc[0][1]       // 12

examples/groovy/match_basename.groovy

text = '/abc/def/da/de/abc_def_ge.txt'
def m = (text =~ /[^\/]*$/)
println m[0]     // abc_def_ge.txt

examples/groovy/regex.groovy

url = 'https://10.11.12.13/some_name'
def match = url =~ '^https?://([^/]*)/([^/]*)$'
println match
println match[0]
println match[0][1]
println match[0][2]