const regex = new RegExp('(?:[A-Za-z0-9!#$%&\\'*+/=?.^_`{|}~-]+(?:.[a-z0-9!#$%&\\'*+/=?^_`{|}~-]+)*|\\"(?:[x01-x08x0bx0cx0e-x1fx21x23-x5bx5d-x7f]|[x01-x09x0bx0cx0e-x7f])*\\")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|[(?:(?:(2(5[0-5]|[0-4][0-9])|1[0-9][0-9]|[1-9]?[0-9])).){3}(?:(2(5[0-5]|[0-4][0-9])|1[0-9][0-9]|[1-9]?[0-9])|[a-z0-9-]*[a-z0-9]:(?:[x01-x08x0bx0cx0e-x1fx21-x5ax53-x7f]|[x01-x09x0bx0cx0e-x7f])+)])', 'gm')
const str = `"Maximilian Milde" <max.milde@freenet.de>,<Telefonkonferenz@telefonkonferenz.de>, "Model Woman, Petra" <muster114@googlemail.com>, 'Sample Lady, Eva' <eva.muda@gmx.net>, "'Sample Man, Bernhard'" <Mustermann.bernhard@t-online.de>, "'Sample Woman, Ute'" <utemusterfrau@gmail.com>, "'Sample, Gisela'" <Giselamuster50@gmx.de>, 'Mumann, Helmut' <hemumann@googlemail.com>, "'Mustermann, Alexander'" <AlexanderMustermann@web.de>, "'Muster, Vera'" <v.muster@web.de>, "'sample woman, Sandra"" <sandra.Musterfrau@gmx.net>, "'Schubert, Ina"" <inas31@gmx.de, Seitz, Irmtraud, Irmtraud.s.e@googlemail.com, Kutz, Holger, Claudia Krüger, Milde, F... Mannheim`;
// 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