use strict;
my $str = 'http://dc778.4shared.com/img/4wW4UT5jba/9f90279b/dlink__2Fdownload_2F4wW4UT5jba_3Ftsid_3D20150615-114008-b7f2dbf8_26lgfp_3D1000_26sbsr_3D7c546ac8da497fae73b10095dc49e8d24e610417724fcf65/preview.wmv
';
my $regex = qr/((http(s)?|ftp)?:\/\/|www\.)dc([0-9])+\.4shared\.com\/([a-z0-9\/@#$,%*_-])+\.?(mp3|mp4|pdf|txt|doc|pps|epub|png|gif|jpg|jpeg|3gp|avi|mpg|wmv|mov|mkv|apk)?/ip;
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