$re = '/^([a-zA-z]{3})(\d{4})(?:\d{2})?(_00)([0-7])(.*)$/m';
$str = 'HTH0919_001-werelwkre;lkj
HTH0919_007_dgfsdfs
HTH0919_008
HTH0919_009
HtH0919_010
HTH0919_097
HTH0919_098
HTH0919_099
HTH0919_100
HTH0919_111
HTH0919_101
HTH0919_899
HTH123456_020
^([a-zA-z]{3})(\\d{4})(?:\\d{2})?(_00)([0-7])(.*)$
^([a-zA-z]{3})(\\d{4})(?:\\d{2})?(_0)(?!98|99)(08|09|[1-9][0-9])(.*)$
^([a-zA-z]{3})(\\d{4})(?:\\d{2})?_(098|099|[1-9][0-9][0-9])(.*)$';
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