It's certainly more concise than my previous favorite, qtext = '[^\\x0d\\x22\\x5c\\x80-\\xff]' dtext = '[^\\x0d\\x5b-\\x5d\\x80-\\xff]' atom = '[^\\x00-\\x20\\x22\\x28\\x29\\x2c\\x2e\\x3a-' + '\\x3c\\x3e\\x40\\x5b-\\x5d\\x7f-\\xff]+' quoted_pair = '\\x5c[\\x00-\\x7f]' domain_literal = "\\x5b(?:#{dtext}|#{quoted_pair})*\\x5d" quoted_string = "\\x22(?:#{qtext}|#{quoted_pair})*\\x22" domain_ref = atom sub_domain = "(?:#…
Perfect email regex finally found
51–60 of 118 posts
Re: Perfect email regex finally found
#52That is part of Lepl - http://www.acooke.org/lepl/ - and although it's implemented in a recursive decent parser, much is compiled to regular expressions for efficiency. So you get the best of all worlds: regexp efficiency; parser accuracy; standards based.
A blog post on the compilation to regexps is here - http://www.acooke.org/cute/LEPLOptimi0.html
Re: Perfect email regex finally found
#53Re: Perfect email regex finally found
#54http://www.messagingnews.com/onmessage/ben-gross/validating-...
Re: Perfect email regex finally found
#55(I know.)
Re: Perfect email regex finally found
#56Earlier quoted context omitted.
Along those lines, I've settled on the following overly permissive regex: /^[^\s@]+@[^\s@]+\.[^\s@]{2,}$/ -- it makes sure it looks something like an email address (a@b.cd)
What if I want to receive mail directly at my TLD?
Re: Perfect email regex finally found
#57Nothing is finished, nothing is permanent, and nothing is perfect. In particular, one of the evaluation tests used here is wrong: it requires failure-to-match on a TLD with a digit in it: numbersInTLD@domain.c0m In fact, IDN TLDs will have digits in them. An internet-draft is in the works to replace RFC1123's IDN-unfriendly implication that digits in TLDs are illegal: http://tools.ietf.org/html/draft-liman-tld-names-…
Re: Perfect email regex finally found
#58How ugly do non-regex based email validation functions look? I've never seen one, but I've always wondered if that was a more elegant solution.
Regex is the only real sensible way to validate strings until something better is found. Even if you just wrote code to do it manually, you'd really just be writing a verbose and poorly implemented finite state machine that globbed symbols together, which in the end, would just be inferior to writing a well tested Regex string. Regex can be easier to read if you have something do a graphical expansion for you. Otherw…
Re: Perfect email regex finally found
#59Earlier quoted context omitted.
Regex is the only real sensible way to validate strings until something better is found. Even if you just wrote code to do it manually, you'd really just be writing a verbose and poorly implemented finite state machine that globbed symbols together, which in the end, would just be inferior to writing a well tested Regex string. Regex can be easier to read if you have something do a graphical expansion for you. Otherw…
> Regex is the only real sensible way to validate strings until something better is found. There are plenty of ‘better’ (in the sense of ‘more powerful’) string-validation techniques. For example, lots of grammars are expressed in BNF; the languages that can be so expressed are (if I remember my Chomsky hierarchy correctly) the context-free grammars, a strictly larger class than the regular languages. The extra power…
Re: Perfect email regex finally found
#60Earlier quoted context omitted.
Along those lines, I've settled on the following overly permissive regex: /^[^\s@]+@[^\s@]+\.[^\s@]{2,}$/ -- it makes sure it looks something like an email address (a@b.cd)
What if I want to receive mail directly at my TLD?