$re = '/(?:https:\/\/goo\.gl\/maps\/\w+)|(?:https:\/\/www\.google\.com\/maps[^ ]*\d)/m';
$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';
preg_match_all($re, $str, $matches, PREG_SET_ORDER, 0);
// Print the entire match result
var_dump($matches);
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 PHP, please visit: http://php.net/manual/en/ref.pcre.php