$re = '~\b\d+(?:,\d+)*~m';
$str = 'this is number 88 and rest of the text
this is number 2,563 and rest of the text
after I export it into excel. Problem is that I\'m using custom tool (not programming language ) that excepts text as an input, regex pattern and export the output. This is why I need single pattern that eliminate space and produce either 88 or 2563 or any other number. The commas are every 3 positions obviously, so it can also be 1,345,321 as well as just single number 5 between "this is number .... and rest of the text"';
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