use strict;
my $str = 'User-Agent: Microsoft-MacOutlook/10.17.1.190326
Date: Wed, 05 Jun 2019 15:04:21 +0800
Subject: FW: DR OKE DANLDAI PLEASEURGENT
From: Dennis Chng <Dennischng@r-logic.com>
To: helpdesk <helpdesk@iqon-asia.com>,
Raynor Tan <raynor@iqon-asia.com>
Message-ID: <IQON.6059aba563.EF09158E-9BED-4A49-AE31-6851E971014F@r-logic.com>
Thread-Topic: DR OKE DANLDAI PLEASE URGENT
References: <341174902.187389.1559716703368.ref@mail.yahoo.com>
<341174902.187389.1559716703368@mail.yahoo.com>
In-Reply-To: <341174902.187389.1559716703368@mail.yahoo.com>
Mime-version: 1.0';
my $regex = qr/^(?=.*\bsubject\b)(?=.([\s\S]*)urgent)(?=.([\s\S]*)yahoo\.com).*$/imp;
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