use strict;
my $str = '< script type="text/javascript" src="//vk.com/js/api/openapi.js?65"> < /script >
<script type="text/javascript" >
VK.init({apiId: 3251711, onlyWidgets: true});
</script>
<script type="text/javascript" src="http://keddr.com/wp-content/themes/keddr3-1/js/lite-youtube.js" ></script>
<script type="text/javascript" src="http://keddr.com/wp-content/themes/keddr3-1/js/jquery.complexify.js" > sfdbb </script>
<script type="text/javascript" >
$(function () {
if (($("#pass1").length 0)) {
$("#pass1").complexify({}, function (valid, complexity) {
if (complexity < 1) {
$(\'#progress\').css({\'width\': complexity + \'%\'}).removeClass(\'progressbarValidGood\').addClass(\'progressbarInvalid\');
$(\'.passAlert\').hide();
} else if (complexity > 1 && complexity < 40) {
$(\'#progress\').css({\'width\': complexity + \'%\'}).removeClass(\'progressbarValidGood\').addClass(\'progressbarInvalid\');
$(\'.passAlert.good\').hide();
$(\'.passAlert.bad\').fadeIn();
} else if (complexity > 40) {
$(\'#progress\').css({\'width\': complexity + \'%\'}).removeClass(\'progressbarValidGood\').addClass(\'progressbarValid\');
$(\'.passAlert.good\').hide();
$(\'.passAlert.strong\').fadeIn();
}
$(\'#complexity\').html(Math.round(complexity) + \'%\');
});
}
});
</script >';
my $regex = qr/<\s*?script\s*?([^>]*)\s*?>\s*?(.+)?\s*?<\s*?\/script\s*?>/sp;
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