$re = '/(time_(?:namelookup|connect|pretransfer|redirect|starttransfer|total))\s*:\s*([+-]?(?:\d*,)?\d+)/m';
$str = 'time_namelookup: 0,121668
time_connect: 0,460643
time_pretransfer: 0,460755
time_redirect: 0,000000
time_starttransfer: 0,811697
time_total: 0,811813
-------------
time_namelookup: 0,121665
time_connect: 0,460643
time_pretransfer: 0,460355
time_redirect: 0,000000
time_starttransfer: 0,813697
time_total: 0,811853
-------------
time_namelookup: 0,121558
time_connect: 0,463243
time_pretransfer: 0,460755
time_redirect: 0,000000
time_starttransfer: 0,911697
time_total: 0,811413 ';
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