Is regular expression recognition of an email address hard?

For the formal e-mail spec, yes, it is technically impossible via Regex due to the recursion of things like comments (especially if you don’t remove comments to whitespace first), and the various different formats (an e-mail address isn’t always [email protected]). You can get close (with some massive and incomprehensible Regex patterns), but a far better way of checking an e-mail is to do the very familiar handshake:

  • they tell you their e-mail
  • you e-mail them a confimation link with a Guid
  • when they click on the link you know that:

    1. the e-mail is correct
    2. it exists
    3. they own it

Far better than blindly accepting an e-mail address.

Leave a Comment