mardi 4 août 2015

Regex to match repeating groups only capturing one group

I want to match the string

6 cakes 5 donuts 12 muffins

into three groups viz. 6 cakes, 5 donuts, 12 muffins. To achieve this I've used the regex

([\d]{1}[\s]{1}[\w]*) 

But the problem is its only matching the first group 6 cakes and ignoring the rest. How can I change it to make the group repeating.

Aucun commentaire:

Enregistrer un commentaire