It's surprisingly a loose definition, as we'll shortly see - and you can go simple or robust on this. When validating emails, or really any input, a good practice, which can more or less guarantee that the user will match the RegEx, is to limit the user input upfront.įor example, mandatory usage of or and straight-up rejecting the non-supported providers (though, you do run into the issue of scalability and staying up-to-date with this approach). However, the one that matches 99.9%, does. If you aren't familiar with Regular Expressions and would like to learn more - read our Guide to Regular Expressions and Matching Strings in JavaScript! Matching Email Formats in JavaScript with Regular Expressionsįirst and foremost, a regular expression that matches all the possible valid email addresses doesn't exist. For the rest of the guide, we will assume that you are somewhat familiar with Regular Expressions.