JavaScript regex for email address validation

I found this helpful page with a nice recipe for email address validation in JavaScript. Unfortunately the regular expression doesn't allow for email addresses with a plus sign in the front part, for example foo+bar@argle.com. These kinds of email addresses are perfectly valid and are used by many to implement disposable email addresses (though I'd recommend Sneakemail myself).

So here's my amended regular expression for validating email addresses. Have I missed anything?

^\w(?:\w|-|\.|\+(?!\.|@))*@\w(?:\w|-|\.(?!\.))*\.\w{2,3}

Before you use this, you might want to read my follow up post with comments from a number of people on the unsuitability of this pattern.

0 responses