< Back to Coding

Good email regex

This is just one I found and seems pretty good

const email_regex = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;

if(formData.email == '' || !formData.email.match(email_regex)){
     hasError = true
}

Leave a Reply

Your email address will not be published. Required fields are marked *