$re = '/(NAME)((\s)?:(\s)?)([ |,| (|)|\\\\|\.|\"|\w|\-|\+]*)((\s)*?,(\s)*?)(DESCR)((\s)?:(\s)?)([ |,| (|)|\\\\|\.|\"|\w|\-|\+]*)(\s)/';
$str = 'WDL3-4N-C4510-1A#show inventory
NAME: "Switch System", DESCR: "Cisco Systems, Inc. WS-C4510R+E 10 slot switch "
PID: WS-C4510R+E , VID: V03 , SN: FOX1616GNS8
NAME: "Clock Module", DESCR: "Clock Module"
PID: WS-X4K-CLOCK-E , VID: V01 , SN: NWG161794PT
NAME: "Mux Buffer 1 ", DESCR: "Mux Buffers for Redundancy Logic"
PID: WS-X4590-EX= , VID: , SN: NWG16179CP9
NAME: "Mux Buffer 2 ", DESCR: "Mux Buffers for Redundancy Logic"
PID: WS-X4590-EX= , VID: , SN: NWG16179C3T
NAME: "Mux Buffer 3 ", DESCR: "Mux Buffers for Redundancy Logic"
PID: WS-X4590-EX= , VID: , SN: NWG16179CUN
NAME: "Mux Buffer 4 ", DESCR: "Mux Buffers for Redundancy Logic"
PID: WS-X4590-EX= , VID: , SN: NWG16179AXZ
NAME: "Mux Buffer 7 ", DESCR: "Mux Buffers for Redundancy Logic"
PID: WS-X4590-EX= , VID: , SN: NWG16179CTE
NAME: "Mux Buffer 8 ", DESCR: "Mux Buffers for Redundancy Logic"
PID: WS-X4590-EX= , VID: , SN: NWG16179C3V
NAME: "Mux Buffer 9 ", DESCR: "Mux Buffers for Redundancy Logic"
PID: WS-X4590-EX= , VID: , SN: NWG16179CLW
NAME: "Mux Buffer 10 ", DESCR: "Mux Buffers for Redundancy Logic"
PID: WS-X4590-EX= , VID: , SN: NWG16179CVU
NAME: "Linecard(slot 1)", DESCR: "10/100/1000BaseT (RJ45)+V E Series with 48 10/100/1000 baseT Premium PoE ports (Cisco/IEEE)"
PID: WS-X4748-RJ45V+E , VID: V03 , SN: CAT1624L2J7
';
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