$re = '/^(?=.*\d)[_0-9]{2}-[_0-9]{3}$/m';
$str = '11-111
_1-111
1_-111
11-__1
11-_1_
11-1__
11-11_
11-1_1
11-_11
11-111
1_-1_1
__-__1
1_-___
__-_1_
_1-___
11-___
__-1__
';
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