use strict;
my $str = 'https://goo.gl/maps/WwcXqVEA5vrEWFtAA
follow this link https://goo.gl/maps/rob6c2k27E4ZpiDd8
https://goo.gl/maps/efNxki1ek7RZ3CAFA need to check in google maps
https://www.google.com/maps/@-6.2964394,107.1813443,3a,75y,90t/data=!3m8!1e2!3m6!1sAF1QipNrLqMTMz-iqWjqvmedTHyQwGLhBE-Z0L46Z5mY!2e10!3e12!6shttps:%2F%2Flh5.googleusercontent.com%2Fp%2FAF1QipNrLqMTMz-iqWjqvmedTHyQwGLhBE-Z0L46Z5mY%3Dw203-h152-k-no!7i1000!8i750 is correct?
https://www.google.com/maps/place/Jl.+Raya+Rw.+Bangkong,+Sertajaya,+Kec.+Cikarang+Tim.,+Bekasi,+Jawa+Barat+17530/@-6.2971014,107.184237,19z/data=!3m1!4b1!4m5!3m4!1s0x2e699b50084e936d:0xc3f7ba2bef9eafc8!8m2!3d-6.2971641!4d107.1847831 how about this? 1234
https://google.com/maps/place/Jl.+Raya+Rw.+Bangkong,+Sertajaya,+Kec.+Cikarang+Tim.,+Bekasi,+Jawa+Barat+17530/@-6.2971014,107.184237,19z/data=!3m1!4b1!4m5!3m4!1s0x2e699b50084e936d:0xc3f7ba2bef9eafc8!8m2!3d-6.2971641!4d107.1847831 how about this? 1234';
my $regex = qr/(?:https:\/\/goo\.gl\/maps\/\w+)|(?:https:\/\/www\.google\.com\/maps[^ ]*\d)/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