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

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

reflection - How to access the object-members of an object declaration in kotlin -

php - Doctrine Query Builder Error on Join: [Syntax Error] line 0, col 87: Error: Expected Literal, got 'JOIN' -