use strict;
my $str = 'https://oedginnrrl.execute-api.us-east-1.amazonaws.com/v1/readstatus?MailingID=112129934&Email=jn47w%40nih.gov"
https://oedginnrrl.execute-api.us-east-1.amazonaws.com/v1/readstatus?MailingID=112131410&Email=james.king%40nih.gov"
http://list.nih.gov/cgi-bin/wa.exe?SUBED1=PHS-AD-PHARMACISTS&A=1
https://oedginnrrl.execute-api.us-east-1.amazonaws.com/v1/readstatus?MailingID=112130096&Email=jerry.suls%40nih.gov"
https://web.streamlinevrs.com/pmt_common/d_images/email_186198972.script
http://www.scripps.edu/>
https://oedginnrrl.execute-api.us-east-1.amazonaws.com/v1/readstatus?MailingID=112129882&Email=james.welch%40nih.gov"
';
my $regex = qr/(?i)(http|https|ftp|ftps)://\S*\.(exe|hta|htr|scr)(\S*|\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