const regex = /.*@softcomputer\.com>? *(?:"? *<\S+> *)?$/gm;
// Alternative syntax using RegExp constructor
// const regex = new RegExp('.*@softcomputer\\.com>? *(?:"? *<\\S+> *)?$', 'gm')
const 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>`;
// Reset `lastIndex` if this regex is defined globally
// regex.lastIndex = 0;
let m;
while ((m = regex.exec(str)) !== null) {
// This is necessary to avoid infinite loops with zero-width matches
if (m.index === regex.lastIndex) {
regex.lastIndex++;
}
// The result can be accessed through the `m`-variable.
m.forEach((match, groupIndex) => {
console.log(`Found match, group ${groupIndex}: ${match}`);
});
}
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 JavaScript, please visit: https://developer.mozilla.org/en/docs/Web/JavaScript/Guide/Regular_Expressions