$re = '/[^\s,;.:-]*\$GNTXT[^\s,;.:-]*|[^\s,;.:-]*S\*12(?=\s)/m';
$str = '?^ ×ô\\ ˜³^ <] Ï|] ci] Þí^ €K` ÙsZ ÑûZ øÔZ ÑûZ -\\ æe^ Ÿ¯T dèZ €NT &ªP ÊY ¹–P èçO nßW ´X clQ ×ô\\ WöV V 4^ ˜³^ *$U ÊY S|R KS }PY ,£R ŒÄN ÑûZ GX íaT ?ŽX >S käP ñÛX 4R îàQ …ÈX ’½P ¢O ¼‘W QýT ;T sY\\ —7U QýT ¼V "¬U Î T VwY ;T "¬U óZV hæU ÃT ›±Y ¾U ÙvN >S ¦«J ,¦F CL bðG jhG ¦ÇµbH ibat3 uA ¸ ô~ ô~ oð$GNTXT,01,01,00,txbuf alloc S*12
haumaukhaS*12
oð$GNTXT
$GNTXT, and that ends with S*12.';
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