$re = '/[^\d,]+|,+\D|\D,+|\d+,\d{3,}|\d{3,}(?:,\d+)?|^,|,$/m';
$str = 'Of course, 22d,3 equals 22,3, or A equals (empty string), 12 equals 12, need to remove anything that\'s not a number and my separator for float is ,
This is a 12 test with 12,34 digits and 123.23 or 123,1 or 123,12 or123,123 and 1234,1 but not 1,234 .html
test-test
34,344
34,34
34,1
34.1
1
1,1
1,12
12
100000
This is a ,comma here and ,,,,,3where ,
,,
,
This is , a a test 10,2333';
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