Question: There are a number of [email](https://stackoverflow.com/questions/156430/regexp-recognition-of-email-address-hard) regexp [questions](https://stackoverflow.com/questions/210945/what-would-be-a-globally-accepted-regular-expression-to-match-e-mail-addresses) popping [up](https://stackoverflow.com/questions/201323/what-is-the-best-regular-expression-for-validating-email-addresses) here, and I'm honestly baffled why people are using these [insanely obtuse](https://stackoverflow.com/questions/156430/regexp-recognition-of-email-address-hard#156469) matching expressions rather than a very simple parser that splits the email up into the name and domain tokens, and then validates those against the valid characters allowed for name (there's no further check that can be done on this portion) and the valid characters for the domain (and I suppose you could add checking for all the world's TLDs, and then another level of second level domains for countries with such (ie, com.uk)).

The real problem is that the tlds and slds keep changing (contrary to popular belief), so you have to keep updating the regexp if you plan on doing all this high level checking whenever the root name servers send down a change.

Why not have a module that simply validates domains, which pulls from a database, or flat file, and optionally checks DNS for matching records?

I'm being serious here, why is everyone so keen on inventing the perfect regexp for this? It doesn't seem to be a suitable solution to the problem...

Convince me that it's not only possible to do in regexp (and satisfy everyone) but that it's a better solution than a custom parser/validator.

-Adam

Answer: 
> 
> and then validates those against the
>  valid characters allowed for name
>  (there's no further check that can be
>  done on this portion)
> 
> 
> 

This is not true. For example, "ben..doom@gmail.com" contains only valid characters in the name section, but is not valid. 

In languages that do not have libraries for email validation, I generally use regex becasue

1. I know regex, and find it easy to use
2. I have many friends who know regex, and I can collaborate with
3. It's fast for me to code, and me-time is more expensive than processor-time for most applications
4. For the majority of email addresses, it works.

I'm sure many built-in libraries do use your approach, and if you want to cover all the possibilities, it does get ridiculous. However, so does your parser. The formal spec for email addresses is absurdly complex. So, we use a regex that gets close enough.
Regexps are much faster to use, of course, and they only validate what's specified in the RFC. Write a custom parser? What? It takes 10 seconds to use a regexp.