use strict;
my $str = 'http://linkedin.com/in/mariam-el-maghrabi-b20b88167
https://www.linkedin.com/in/bhupad-rathi-33b69118b
https://www.linkedin.com/in/hassen-hamza-b7350013/
https://www.linkedin.com/in/safna-senna-1781a8193/
https://www.linkedin.com/in/balaji-mutyala-7b9a3916b/
https://www.linkedin.com/in/adnan-alkeba/
https://www.linkedin.com/in/ahmed-mouniir/
https://www.linkedin.com/in/louay-alshoum
https://linkedin.com/in/exyfi
https://www.linkedin.com/in/mohammed-elsheikh-889353102/
https://www.linkedin.com/in/%C5%9Fahin-e%C4%9Filmez-856631114/';
my $regex = qr/^(http(s)?:\/\/)?(www\.)?linkedin\.([a-z]+)\/in\/[\p{L}\p{N}\p{M}_-]{3,100}\/?$/iup;
if ( $str =~ /$regex/ ) {
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