In Javascript I'm trying exclude a specific mail domain and all its subdomains using regex. If the domain I want to exclude is spammail.com. I need to exclude all the following
name@spammail.com
name@xx.spammail.com
name@xxx.spammail.com
...
In Javascript I'm trying exclude a specific mail domain and all its subdomains using regex. If the domain I want to exclude is spammail.com. I need to exclude all the following
name@spammail.com
name@xx.spammail.com
name@xxx.spammail.com
...
Try like this:
let checkValid = (mail) => !/([^\@]*\@)(([^\.]*\.{1})*)(spammail\.com)/.test(mail);
console.log(checkValid("name@spammail.com")) //false
console.log(checkValid("name@xx.spammail.com")) //false
console.log(checkValid("name@xxx.spammail.com")) //false
console.log(checkValid("name@notspammail.com")) //true
console.log(checkValid("name@xxxspammail.com")) //true