The RFC822 validation monster
(?:(?:\r\n)?[ \t])*(?:(?:(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t]
Validating email addresses has always been a pain and there is no perfect solution. Even if you were to pass the above validation, there’s no guarantee the provided address actually exists.
Fortunately there was some good advice for the sanest way to deal with addresses. To summarise:
- The only way to know if an email is valid is to send one.
- There is a recommended regex in the HTML5 spec.
- A really simple approach is check for a character either side of an @ before sending an email.
To get an idea of the kinds of addresses which lead to such a monstrous regex, check out this list.
Photo credit to Markus Spiske