$re = '/^\s*(\d{1,3})\s+([a-zA-z0-9-_]+\s?[a-zA-z0-9-_]+)\s+(0x[a-zA-Z0-9]{4})\s+(\d{3})\s+(\d{3})\s+(\d+)\s+([a-zA-z0-9-_]+\s?\w+)\s+(\w+)\s+-\s+(\d+)/m';
$str = 'ID# ATTRIBUTE_NAME FLAG VALUE WORST THRESH TYPE UPDATED WHEN_FAILED RAW_VALUE
5 Reallocated_Sector_Ct 0x0033 100 100 010 Pre-fail Always - 0
9 Power_On_Hours 0x0032 096 096 000 Old_age Always - 19033
12 Power_Cycle_Count 0x0032 099 099 000 Old_age Always - 54
170 Unused_Rsvd_Blk_Ct_Chip 0x0032 100 100 010 Old_age Always - 0
171 Program_Fail_Count_Chip 0x0032 100 100 010 Old_age Always - 0
172 Erase_Fail_Count_Chip 0x0032 100 100 010 Old_age Always - 0
173 Wear_Leveling_Count 0x0033 090 090 005 Pre-fail Always - 121
174 Unexpect_Power_Loss_Ct 0x0032 099 099 000 Old_age Always - 12
178 Used_Rsvd_Blk_Cnt_Chip 0x0013 100 100 010 Pre-fail Always - 0
180 Unused_Rsvd_Blk_Cnt_Tot 0x0013 100 100 010 Pre-fail Always - 1618
184 End-to-End_Error 0x0033 100 100 097 Pre-fail Always - 0
187 Uncorrectable_Error_Cnt 0x0032 100 100 000 Old_age Always - 0
194 Temperature_Celsius 0x0032 059 055 000 Old_age Always - 41
199 CRC_Error_Count 0x003e 099 099 000 Old_age Always - 21
233 Media_Wearout_Indicator 0x0013 090 090 000 Pre-fail Always - 15085512
241 Total_LBAs_Written 0x0032 099 099 000 Old_age Always - 19103
242 Total_LBAs_Read 0x0032 099 099 000 Old_age Always - 23403
249 NAND_Writes_1GiB 0x0032 099 099 000 Old_age Always - 61952';
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