Once upon a time, I read somewhere in a book (whose name escapes me) that to PROPERLY validate an email address, the regex was somewhere in the neighborhood of 200 lines of code. (It probably has something to do with all the country domains.) That number has probably gone up since then.
I passed that bit of trivia to a fellow coder, but realized I couldn't source it.
It's probably locked away in a Perl function somewhere, but I don't know Perl nor the Perl community. (Or that could be a red herring).
In any case, does anyone here have any recollection to that effect and where I could source it?

Recommended Answers

All 3 Replies

Validating country domains seems like a silly way of validating email addresses. .com is a valid domain but dani@skdjflksdfjlksd.com is not a valid email address :)

I would use regex on the part before the @ to make sure there are no invalid characters and to test its length, etc. But then I would use cURL or something to make sure that the domain name is actually valid.

well, it is a valid email address, just not an existing one.

That validator probably knew about a lot more address forms than just the (now) normal name@domain.tld form.
E.g. Lotus Notes, Novell Netware, and many other network systems all had/have their own addressing systems and while now seeming archaic in the past a generic address validator had to take all of them into account.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.