use strict;
my $str = 'ACTIONS:
[ { LONGITUDES:
{ SHUTTLE_LON_A6: [ 748, [ \'CI\', 76.5, 980.5 ] ],
SHUTTLE_LON_A5:
[ 271,
[ \'CL\', 0, 76.5 ],
[ \'CI\', 76.5, 980.5 ],
[ \'CL\', 980.5, 1057 ] ],
SHUTTLE_LON_A4: [ 129 ],
SHUTTLE_LON_A3: [ 107 ],
SHUTTLE_LON_A2: [ -35 ],
SHUTTLE_LON_A1: [ -57 ] },
LATITUDES: { SHUTTLE_LAT_1: [ [ 1057 ] ] } },
{ LONGITUDES:
{ SHUTTLE_LON_A6: [ 978, [ \'CL\', 76.5, 980.5 ] ],
SHUTTLE_LON_A5:
[ 727,
[ \'CL\', 0, 76.5 ],
[ \'CI\', 76.5, 980.5 ],
[ \'CL\', 980.5, 1057 ] ],
SHUTTLE_LON_A4: [ 250, [ \'CI\', 76.5, 980.5 ] ],
SHUTTLE_LON_A3: [ 20, [ \'CL\', 76.5, 980.5 ] ],
SHUTTLE_LON_A2: [ -122 ],
SHUTTLE_LON_A1: [ -144 ] },
LATITUDES:
{ SHUTTLE_LAT_1:
[ [ 20.5, [ \'CI\', 0, 1100 ] ],
[ 34.5, [ \'CI\', 0, 1100 ] ],
[ 58.5, [ \'CI\', 0, 1100 ] ],
[ 76.5,
[ \'CL\', 0, 271 ],
[ \'CI\', 271, 727 ],
[ \'CL\', 727, 1100 ] ],
[ 980.5,
[ \'CL\', 0, 271 ],
[ \'CI\', 271, 727 ],
[ \'CL\', 727, 1100 ] ],
[ 998.5, [ \'CI\', 0, 1100 ] ],
[ 1022.5, [ \'CI\', 0, 1100 ] ],
[ 1036.5, [ \'CI\', 0, 1100 ] ],
[ 1057, [ \'CL\', 0, 1100 ] ],
[ 1057 ] ] } } ] } ]';
my $regex = qr`(S\w.*\d[:])|(([0-9.]+|(-[0-9.]+)))|([A-Z]{2}\b)`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