Hacker News new | past | comments | ask | show | jobs | submit login

Somewhat unrelated, but out of curiosity, does anyone know of a site that lists — for all popular languages — various libraries/code snippets/routines which one can use to correctly (according to the RFCs) check the validity of e-mail addresses?

If not I may be compelled to create one.




The HTML5 standard actually defines a mostly-sane regex, which achieves that sanity through "a willful violation of RFC 5322, which defines a syntax for e-mail addresses that is simultaneously too strict (before the "@" character), too vague (after the "@" character), and too lax (allowing comments, whitespace characters, and quoted strings in manners unfamiliar to most users) to be of practical use here."

I like it.

Link: http://www.whatwg.org/specs/web-apps/current-work/multipage/...


The RFC-compliant email address is actually incredibly complex. There are loads of things that are RFC-valid email addresses that basically hardly anyone uses (like spaces).


Just send an email and see if it arrives.


/.@./ is pretty much the best you can do.

And even the dots are a bit iffy.


@"^[^@]{1,}[@]{1}[^@]{1,}\.{1}[^@]{1,}$"

I check it with this RegEx to make sure it's in the right format of [string]@[string].[string] to make sure that user at least tries to enter an email address, but beyond that sending and email and getting a response is the only way.


> @"^[^@]{1,}[@]{1}[^@]{1,}\.{1}[^@]{1,}$"

Is not

> [string]@[string].[string]

It's mere ^.+@.+\..+ (in both POSIX extended and PCRE dialects) that properly represents the latter.

And even such regexp filters out many technically-valid but obscure cases of RFC-compliant email addresses (for example ai, io, kh and ws TLDs have MX records, and supposedly hostmaster@io should be a valid email address).


Check out this incredibly complex rfc822 regex in action: http://regex101.com/r/fZ6cD5


There isn't. Look up the regex for validating an email address it you'd like to know why.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: