use strict;
my $str = 'test comment reply in email
On 10.05.2016 16:06, MRKTNG wrote:
> New Message
> MRKTNG <#>
>
> Your Profile Picture
>
> Lisa Radzishevsky <#>
> May 10, 2016, 8:06 am
>
>
>
>
>
> RE: Language learning
>
> test subject
>
>
> Reply
> <http://mandrillapp.com/track/click/30047086/vendori.local?p=eyJzIjoiLXVwS2lWRndOUXVibWozbmFVQ09qbVE3ZVdjIiwidiI6MSwicCI6IntcInVcIjozMDA0NzA4NixcInZcIjoxLFwidXJsXCI6XCJodHRwOlxcXC9cXFwvdmVuZG9yaS5sb2NhbFxcXC9kb2N1bWVudFxcXC80ODEwNCNkaXNjdXNzaW9uXCIsXCJpZFwiOlwiY2YwYWFhNWE1ZWY5NDZmMDhlNjJmNmRiMTAyZDY4Y2VcIixcInVybF9pZHNcIjpbXCJhYzE1OWI2NTM2YTM0ZDkzYmU1MzE5Y2VmN2IzOWEwZGQzMjY2NWRkXCJdfSJ9>
>
>
> © 2015 MRKTNG. All Rights Reserved.
> 1 W Superior St. • Chicago • IL 60654 USA <#>
>
';
my $regex = qr/(On\s.*<\n){0,1}(.*\n(\n){0,1}((^>+\s?.*$)+\n?)+)/mip;
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