use strict;
my $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.';
my $regex = qr/[^\s,;.:-]*\$GNTXT[^\s,;.:-]*|[^\s,;.:-]*S\*12(?=\s)/mp;
if ( $str =~ /$regex/g ) {
print "Whole match is ${^MATCH} and its start/end positions can be obtained via \$-[0] and \$+[0]\n";
# print "Capture Group 1 is $1 and its start/end positions can be obtained via \$-[1] and \$+[1]\n";
# print "Capture Group 2 is $2 ... and so on\n";
}
# ${^POSTMATCH} and ${^PREMATCH} are also available with the use of '/p'
# Named capture groups can be called via $+{name}
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 Perl, please visit: http://perldoc.perl.org/perlre.html