const regex = /(gmai|ggmail|gmial|gmaol|gmil|iclould|gmeil|iclouds|icoud|hotmial|yahio|gmell|hotmil|gmailz|iclound|gmaio|gmile|gmaul|iclud|gmsil|gamil|ail|gnail|yhoo|gmal|gmaill|yaho|yshoo|gimail|gemail|gmail\.com)\.(com)$/img;
// Alternative syntax using RegExp constructor
// const regex = new RegExp('(gmai|ggmail|gmial|gmaol|gmil|iclould|gmeil|iclouds|icoud|hotmial|yahio|gmell|hotmil|gmailz|iclound|gmaio|gmile|gmaul|iclud|gmsil|gamil|ail|gnail|yhoo|gmal|gmaill|yaho|yshoo|gimail|gemail|gmail\\.com)\\.(com)$', 'img')
const str = `gmai.com
gmial.com
gmaol.com
gmil.com
iclould.com
gmeil.com
iclouds.com
icoud.com
ggmail.com
hotmial.com
yahio.com
gmell.com
hotmil.com
gmailz.com
iclound.com
gmaio.com
gmile.com
gmaul.com
iclould.com
gmaul.com
iclud.com
gmsil.com
yahoo.con
gamil.com
gmail.co
ail.com
gnail.com
gmal.com
gail.com
yhoo.com
hmail.com
gmaill.com
yaho.com
yshoo.com
g.mail.com
yahoo.co
g-mail.com
gmail.comm
gmail.vom
icloud.con
hotmail.con
gimail.com
gmail.cim
gemail.com
gmail.com.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