$re = '/^(0[1-9]\d|0\d[1-9]|6[0-57-9]\d|6\d[0-57-9]|[1-57-8]\d\d)-\d{2}-\d{4}$/m';
$str = '123-45-6789
123456789
001341343
888-03-1785
888-04-0001
606-04-0001
660-04-0001
666-23-1234
666231234
000-65-1343
000651343
905-31-6375
905316375
888-00-1785
888001785
888-04-0000
888040000
666-00-0000
666-01-4050';
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