const regex = /(?:[A-Za-z0-9!#$%&'*+\/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+\/=?^_`{|}~-]+)*|"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])/gm;
// Alternative syntax using RegExp constructor
// const regex = new RegExp('(?:[A-Za-z0-9!#$%&\'*+\\\/=?^_`{|}~-]+(?:\\.[a-z0-9!#$%&\'*+\\\/=?^_`{|}~-]+)*|"(?:[\\x01-\\x08\\x0b\\x0c\\x0e-\\x1f\\x21\\x23-\\x5b\\x5d-\\x7f]|\\\\[\\x01-\\x09\\x0b\\x0c\\x0e-\\x7f])*")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-]*[a-z0-9]:(?:[\\x01-\\x08\\x0b\\x0c\\x0e-\\x1f\\x21-\\x5a\\x53-\\x7f]|\\\\[\\x01-\\x09\\x0b\\x0c\\x0e-\\x7f])+)\\])', 'gm')
const str = `David Hills
Primeresllc@gmail.com
· Reply · 42w
Adrian Chu
badge icon
adrian@adrianchu.net
· Reply · 42w
Nick Bagoshvili
badge icon
Nick@ngbroofing.com
· Reply · 42w
Grace Wang
grace@ClarityPropertiesLLC.com
· Reply · 42w
Pete Venturo
That's my neighbor.
· Reply · 42w
Hom Teang
mrteang@gmail.com
· Reply · 42w
Derek Stephens
derek@summitreiholdings.com
· Reply · 42w
Julie K Clark
Julie@seattleinvestorsclub.com
· Reply · 42w
Alex Frankov
alexfrankov@hotmail.com
· Reply · 42w
Dawn Armstrong
Dawnarmstrong&hotmail.com
Outlook – free personal email and calendar from Microsoft
OUTLOOK.LIVE.COM
Outlook – free personal email and calendar from Microsoft
Outlook – free personal email and calendar from Microsoft
· Reply · 42w
Andrey Gulyy
Andreygulyyre@gmail.com please
· Reply · 42w
Viktor Bondarenko
viktor76@outlook.com
· Reply · 42w
Jeremy Macconnell
Sendmeyourdeals@foursqre.com
· Reply · 42w
A Suraphong Liengboonlertchai
Abuysellproperty@gmail.com. Thx 🙏
· Reply · 42w
Kellen Giroux
info@upraisedproperties.com
· Reply · 42w
Anthony Markiie Prado
Amprado@kw.com
· Reply · 42w
Jamil Newman
Westshoreinvestmentgroup@gmail.com
· Reply · 42w
Joe Clark
Josephclark10@gmail.com
· Reply · 42w
Nick Taitano
It's a great opportunity!
· Reply · 41w
Miao Jiang
mj@everestinvestments.net
· Reply · 41w
AJ Sheffield
aj@theoffmarketdeals.com
· Reply · 41w
Cindy Highsmith
Flyfreelw@gmail.com
· Reply · 41w
Steven Wang
stevenwproperties@gmail.com
· Reply · 41w
Miao Jiang
mj@everestinvestments.net
· Reply · 40w
Les Dreeson
ldreeson@listings.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