$re = '/P1127_VELOCITIES #001000 Step: (\d+) Iteration: (\d+) Time: (\d+\.\d+) {1,2}(\d*\.\d+|-\d*\.\d+)/m';
$str = 'Number of zero columns: 4
Memory requirement - global matrix: 1571340 solver (totally): 1571340
P1127_VELOCITIES #001000 Step: 59 Iteration: 2 Time: 0.04055 0.0015347
P2243_VELOCITIES #001000 Step: 59 Iteration: 2 Time: 0.04055 0.0017193
P3387_VELOCITIES #001000 Step: 59 Iteration: 2 Time: 0.04055 0.0015347
% of load in interval Step: 59 Iteration: 2 Time: 0.04055 0.0400000 0.0400000
summation % of load in interval Step: 59 Iteration: 2 Time: 0.04055 0.0800000
Number of zero columns: 4
Memory requirement - global matrix: 1571340 solver (totally): 1571340
P1127_VELOCITIES #001000 Step: 59 Iteration: 2 Time: 0.01638 -0.0016876
P2243_VELOCITIES #001000 Step: 59 Iteration: 2 Time: 0.01638 -0.0018896
P3387_VELOCITIES #001000 Step: 59 Iteration: 2 Time: 0.01638 -0.0016876
% of load in interval Step: 59 Iteration: 2 Time: 0.01638 0.0400000 0.0400000
summation % of load in interval Step: 59 Iteration: 2 Time: 0.01638 0.0800000 ';
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