How to make preg_match regular expression?

Make a regular expression: text-any number of spaces-digits separated by commas. Example:

example 12,14,15,25,323

Should parse

[1]=>example
[2]=>12
[3]=>14
[4]=>15

etc

And then everything is so sad for me 🙂


Answer 1, authority 100%

$str = 'example 12,14,15,25,323 example-two 142,14,15,25,323, etc';
preg_match_all('/([\d\w\-]+),?/', $str, $matches);
print_r($matches);

Answer 2, authority 50%

$result = preg_split('/[\s,]+/', 'example 12,14,15,25,323');