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 -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -