What is a good regular expression for catching typos in an email address? [closed]

It’s possible to write a regular expression that only accept email addresses that follow the standards. However, there are some email addresses out there that doesn’t strictly follow the standards, but still work.

Here are some simple regular expressions for basic validation:

Contains a @ character:

@

Contains @ and a period somewhere after it:

@.*?\.

Has at least one character before the @, before the period and after it:

.+@.+\..+

Has only one @, at least one character before the @, before the period and after it:

^[^@]+@[^@]+\.[^@]+$

User AmoebaMan17 suggests this modification to eliminate whitespace:

^[^@\s]+@[^@\s]+\.[^@\s]+$

And for accepting only one period [external edit: not recommended, does not match valid email adresses]:

^[^@\s]+@[^@\s\.]+\.[^@\.\s]+$

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)