use strict;
my $str = '/data=!4m7!3m6!1s0x54905cd11489942f:0x6a68c79cf58b8d9!8m2!3d47.4556324!4d-122.2566178!16s%2Fg%2F1tvtb18c!19sChIJL5SJFNFckFQR2bhYz3mMpgY?authuser=0&hl=en&rclk=1
/data=!4m7!3m6!1s0x54906acdccf44db1:0x6da0c1f2d7a6736e!8m2!3d47.61404!4d-122.3281!16s%2Fg%2F11b6hykyrc!19sChIJsU30zM1qkFQRbnOm1_LBoG0?authuser=0&hl=en&rclk=1';
my $regex = qr/!1s(?<id>[^!]+).+!3d(?<latitude>[^!]+)!4d(?<longitude>[^!]+)/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