use strict;
my $str = '<p> demo <p>..</p>demo:</p> <p ><img src="http://demo.com/123.jpg" width="100%"/> <br/> <em>Credit: demo2 demo2 </em></p> <p >here1 here1:</p> <blockquote cite="here1"> <p><em>demo3. demo3 demo3 demo3:</em></p> </blockquote> <p >demo4 demo4:</p> <p ><img src="http://demo.com/1234.jpg" width="100%"/> <br/> <em>demo5 demo 5 demo5</em></p> <p >demo6 demo6:</p> <blockquote cite="demo6"> <p><em>demo7 demo7<br/>';
my $regex = qr/ <p[^>]*>((?:(?!<\/p>).)+)<\/p>\s*<blockquote[^>]*>(.*?)<\/blockquote>/p;
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