$re = '/^(?:[1-9][0-9]*?,?[0-9]{1,2}|[0](?:,[0-9]{1,2})?|)$/m';
$str = 'Input amount is not a string (only number 0-9)
Adwad,321 d3,232,123,A;d,aw
123456789
Separator must be ","
12.1
12,1
I need max 2 decimal places
17,234236
17,23
I can\'t accept any characters, except of numbers 0-9 and ","
321d,3e16
-323,3
123,45
Input amount cannot be less than 0
-1
0
0,01
Input amount has to start from a number
a31233
,321
1232
extra; does not allow "fake/mal-formatted" numbers
0312312
032312
extra 2; doesnt last character to be ","
1,0
1,
0,12
0,
3123,';
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