$re = '/^(?:-9223372036854775808|-?(?:\d{0,18}|(?!922337203685477580[8-9]|9223372036854775[9-9]|922337203685477[6-9]|92233720368547[8-9]|9223372036854[8-9]|922337203685[5-9]|92233720368[6-9]|9223372036[9-9]|922337203[7-9]|92233720[4-9]|922337[3-9]|92233[8-9]|9223[4-9]|922[4-9]|92[3-9]|9[3-9])\d{19}))$/m';
$str = '-9223372036854775807
-9223372036854775808
-9223372036854775809
9223372036854775806
9223372036854775807
9223372036854775808
-922337203685477580
922337203685477580';
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