$re = '~^(\w+)\W+\w+\W+(\w+)~m';
$str = 'health status index pri rep docs.count docs.deleted store.size pri.store.size
yellow open first_index 5 1 222173 0 43.8gb 43.8gb
green open second_index 5 1 27131 7 36.6gb 36.6gb
red open third_index 5 1 4047 0 22.4mb 22.4mb
';
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