$re = '/(?<=^|\s)(?:(?:0|[1-9][0-9]{0,2}(?:,[0-9]{3})*))(?=\s|$)/';
$str = 'So hopefully will match 1,234 and 23,322 and 1,234,567 and 12 but not 1,23,1 or ,,1111, or anything else silly.
213,213,213
16,587,684,324
654,674,684
6,764,324
65,647,534
8,743,213
313,546
576,476
55,455
5,789
1
12
123
4,565
089
0,457
004,457
ajdgasj kadfshk 4d 5 kdhkds 5
5 sdfsdf
0
sadfasdfkj 7,456,464,646 adsff 6,565,454';
preg_match_all($re, $str, $matches, PREG_SET_ORDER, 0);
// Print the entire match result
var_dump($matches);
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for PHP, please visit: http://php.net/manual/en/ref.pcre.php