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.'
# Print the match result
str.scan(re) do |match|
puts match.to_s
end
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 Ruby, please visit: http://ruby-doc.org/core-2.2.0/Regexp.html