$re = '/^(?:[0-9]+\n|\n)(([0-9:,]+)([\s->]+)([0-9:,]+))$/m';
$str = '1
00:00:04,019 --> 00:00:07,299
- cdcdc
- cddcd
2
00:00:07,414 --> 00:00:09,155
54564
00:00:09,276 --> 00:00:11,429
- 445454 - ccd
- cdscdcdcd
00:00:11,549 --> 00:00:14,874
line1
line2
';
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