$re = '/((?:\d{2}:)?\d{2}:\d{2}\.\d{3})[^\n]+level[^\d]+(\d{3})/m';
$str = '00:00.300 ID:4 zzzzzzzzzzz
00:02.155 ID:4 aaaaaaaaaaaaa
00:04.662 ID:4 dsadasd
**00:32.283** ID:4 level **790**
00:32.155 ID:4 Sfghgfs
00:32.200 ID:4 Tsdfsdfdfsff
**00:32.205** ID:4 level **640**
00:32.206 ID:4 Sadssd
00:32.208 ID:4 asdasgsfgsgsagsa
00:32.210 ID:4 adasgx
00:32.212 ID:4 Masddasdas.
**01:40:40.698** ID:4 level **500**';
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