groovy - How to find all matches of a pattern in a string using regex -
if have string like:
s = "this simple string 234 else here 4334
and regular expression like:
regex = ~"[0-9]{3}"
how can extract words string using regex? in case 234
, 433
?
it's shorter do
def triads = s.findall("[0-9]{3}") assert triads == ['234', '433']
Comments
Post a Comment