use strict;
my $str = '== Real scc
Mary Bills <marybil@softcomputer.com>
<ellie@softcomputer.com>
<thereasaw@softcomputer.com>
test@softcomputer.com
<test@softcomputer.com>
olexiyry@softcomputer.com <olexiyry@softcomputer.com>
Deseriee Harkins <deseriee@softcomputer.com>
== Forged scc
Dorota Mazurek <dorotam@softcomputer.com> <reservations@nesthotel.com>
Nikki Taft <nicolet@softcomputer.com> <Muhammad.owais@abtach.com>
Lynette Didia <ldidia@softcomputer.com> <Muhammad.owais@abtach.com>
Dorota Mazurek <dorotam@softcomputer.com> <centralbookings@kbcsa.co.za>
Jeffrey Marr <jeffreym@softcomputer.com> <srvadv5.blr@vw-ppsmotors.co.in>
Iryna Dmytriyeva @SCC <idmy@softcomputer.com> <sc@grupoinrexsa.com>
Vickie Nix vickieh@softcomputer.com <m.recovery@albarondebt.com>
Bill Young <billyo@softcomputer.com> <sara@eaurenaissance.com>
== Questionable
"Kurt Veith <kurtv@softcomputer.com>" <marlene.robles@mld.com.mx>
"softcomputer.com" <MAIL.QUOTA@servers.com>
"marksm@softcomputer.com" <mark560sl@gmail.com>
== Valid non-forged addresses
"sarahze@softcomputer.com via Smartsheet" <user@smartsheet.com>
"yuvi softcomputer.com" <hugginshospital.notification@zixmessagecenter.com>
<technicalsupport@softcomputer.com.au>
"Secure Email From yevgeny@softcomputer.com via Message Pickup Center" <emx-intermedia@securemail.intermedia.net>
"Secure Email From yevgeny@softcomputer.com via Message Pickup Center" <emx-intermedia@securemail.intermedia.net>
"mpettis@softcomputer.com via SurveyMonkey" <member@surveymonkeyuser.com>';
my $regex = qr/.*@softcomputer\.com>? *(?:"? *<\S+> *)?$/mp;
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