$re = '/(?<![0-9])([0-9]{1,3}?)([0-9]{3})([0-9]{3})(?![0-9]+?)/m';
$str = 'Lorem 100 ipsum dolor 1000 sit 200 amet, 2000 consectetur adipiscing elit, sed 20000 do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in 300 voluptate 3000 velit esse 30000 cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat 400 cupidatat 4000 non proident, 40000 sunt in culpa qui 100000 officia 200000 deserunt mollit 300000 anim id 1234567 est 12345678 la 123456789 borum 123456789 ad more 1234567891 foo.';
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