use strict;
my $str = 'appro@openssl.org
appro@openssl.org
appro@openssl.org
appro@openssl.org
appro@openssl.org
http://www.openssl.org/support/faq.html
www.openssl.org/support/faq.html
http://www.openssl.org/support/faq.html
d.compressedData
https://
http://zip.allnetserveline.com/crossbrowse/chrome/chrome.zip.001
http://zip.allnetserveline.com/crossbrowse/chrome/chrome.zip.001
http://zip.allnetserveline.com/crossbrowse/chrome/chrome.zip.002
http://zip.allnetserveline.com/crossbrowse/chrome/chrome.zip.002
http://zip.allnetserveline.com/crossbrowse/chrome/chrome.zip.003
http://zip.allnetserveline.com/crossbrowse/chrome/chrome.zip.003
http://zip.allnetserveline.com/crossbrowse/chrome/chrome.zip.004
http://zip.allnetserveline.com/crossbrowse/chrome/chrome.zip.004
http://zip.allnetserveline.com/crossbrowse/chrome/chrome.zip.005
http://zip.allnetserveline.com/crossbrowse/chrome/chrome.zip.005
http://zipf.allnetserveline.com/crossbrowse/chrome/chrome.zip.001
http://zipf.allnetserveline.com/crossbrowse/chrome/chrome.zip.001
http://zipf.allnetserveline.com/crossbrowse/chrome/chrome.zip.002
http://zipf.allnetserveline.com/crossbrowse/chrome/chrome.zip.002
http://zipf.allnetserveline.com/crossbrowse/chrome/chrome.zip.003
http://zipf.allnetserveline.com/crossbrowse/chrome/chrome.zip.003
http://zipf.allnetserveline.com/crossbrowse/chrome/chrome.zip.004
http://zipf.allnetserveline.com/crossbrowse/chrome/chrome.zip.004
http://zipf.allnetserveline.com/crossbrowse/chrome/chrome.zip.005
http://zipf.allnetserveline.com/crossbrowse/chrome/chrome.zip.005
http://err.allnetserveline.com
http://err.allnetserveline.com
http://logs.allnetserveline.com
http://logs.allnetserveline.com
http://stats.allnetserveline.com
http://stats.allnetserveline.com
http://js.allnetserveline.com/crossbrowse/js/{{camp_id}}/{{secret}}/ch.js
http://js.allnetserveline.com/crossbrowse/js/{{camp_id}}/{{secret}}/ch.js
http://srch.allnetserveline.com/crossbrowse/sch/{{camp_id}}/{{secret}}/ch.json
http://srch.allnetserveline.com/crossbrowse/sch/{{camp_id}}/{{secret}}/ch.json
http://js.allnetserveline.com/crossbrowse/js/{{camp_id}}/{{secret}}/ch.js
http://js.allnetserveline.com/crossbrowse/js/{{camp_id}}/{{secret}}/ch.js
http://srch.allnetserveline.com/crossbrowse/sch/{{camp_id}}/{{secret}}/ch.json
http://srch.allnetserveline.com/crossbrowse/sch/{{camp_id}}/{{secret}}/ch.json
http://update.allnetserveline.com/crossbrowse/updater/{{camp_id}}/{{version}}/{{secret}}/update.json
http://update.allnetserveline.com/crossbrowse/updater/{{camp_id}}/{{version}}/{{secret}}/update.json
http://ipgeoapi.com/
http://ipgeoapi.com/
';
my $regex = qr/(http|https|ftp)\://([a-zA-Z0-9\-\.]+\.+[a-zA-Z]{2,3})(:[a-zA-Z0-9]*)?/?([a-zA-Z0-9\-\._\?\,\'/\\\+&%\$#\=~]*)[^\.\,\)\(\s]?/p;
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