$re = '/^\s*(\d{1,3})\s+([\w-]+)\s+(0x[\da-fA-F]{4})\s+(\d{3})\s+(\d{3})\s+(\d+)\s+([\w-]+)\s+(\w+)\s+-\s+(\d+)/m';
$str = 'ID# ATTRIBUTE_NAME FLAG VALUE WORST THRESH TYPE UPDATED WHEN_FAILED RAW_VALUE
1 Raw_Read_Error_Rate 0x002f 100 100 050 Pre-fail Always - 0
5 Reallocated_Sector_Ct 0x0032 100 100 001 Old_age Always - 0
9 Power_On_Hours 0x0032 100 100 000 Old_age Always - 18322
12 Power_Cycle_Count 0x0032 100 100 001 Old_age Always - 608
170 Reserved_Block_Pct 0x0033 100 100 010 Pre-fail Always - 0
171 Program_Fail_Count 0x0032 100 100 000 Old_age Always - 0
172 Erase_Fail_Count 0x0032 100 100 001 Old_age Always - 0
173 Avg_Block-Erase_Count 0x0032 100 100 000 Old_age Always - 1
174 Unexpect_Power_Loss_Ct 0x0032 100 100 000 Old_age Always - 131
183 SATA_Int_Downshift_Ct 0x0032 100 100 000 Old_age Always - 0
184 End-to-End_Error 0x0032 100 100 000 Old_age Always - 0
187 Reported_Uncorrect 0x0032 100 100 000 Old_age Always - 0
188 Command_Timeout 0x0032 100 100 000 Old_age Always - 597
194 Temperature_Celsius 0x0022 064 056 000 Old_age Always - 36 (Min/Max 16/44)
195 Hardware_ECC_Recovered 0x0032 100 100 000 Old_age Always - 0
196 Reallocated_Event_Count 0x0032 100 100 000 Old_age Always - 0
197 Current_Pending_Sector 0x0032 100 100 000 Old_age Always - 0
198 Offline_Uncorrectable 0x0030 100 100 000 Old_age Offline - 0
199 UDMA_CRC_Error_Count 0x0032 100 100 000 Old_age Always - 0
202 Percent_Lifetime_Remain 0x0030 100 100 001 Old_age Offline - 0
206 Write_Error_Rate 0x000e 100 100 000 Old_age Always - 0
246 Total_LBAs_Written 0x0032 100 100 000 Old_age Always - 582369015
247 Host_Program_Page_Count 0x0032 100 100 000 Old_age Always - 18199054
248 Bckgnd_Program_Page_Cnt 0x0032 100 100 000 Old_age Always - 22876012
180 Unused_Rsvd_Blk_Cnt_Tot 0x0033 000 000 000 Pre-fail Always - 18839
210 RAIN_Success_Recovered 0x0032 100 100 000 Old_age Always - 0
211 Integ_Scan_Complete_Cnt 0x0032 100 100 000 Old_age Always - 738
212 Integ_Scan_Folding_Cnt 0x0032 100 100 000 Old_age Always - 0';
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