News for hackers. Stuff that matters.
Re:Perfect email regex finally found by adamc on Friday May 28, 2010 @04:21PM (#1387530)
That's just silly. Depending on what's in the string, writing a parser might be much better than a regex. Lots of parser libraries already out there, too.
Re:Perfect email regex finally found by Ixiaus on Friday May 28, 2010 @04:37PM (#1387589)
I can agree with this sentiment, there's also nothing wrong with writing a parser that breaks the input up into pieces and validates those individual parts using specialized regular expressions.
Re:Perfect email regex finally found by aphyr on Friday May 28, 2010 @04:52PM (#1387625)
Especially when the spec itself is in EBNF.
Re:Perfect email regex finally found by _delirium on Friday May 28, 2010 @04:56PM (#1387636)
True, though it's EBNF with a bunch of explanatory text and annotations.

What would be interesting, but I can't find with some googling: Has someone implemented a parser-generator based on the spec? The ideal would be that the parser specification looks a lot like the RFC, since then you'd have more confidence it was actually correct (and it'd be easier to maintain for future changes).

Re:Perfect email regex finally found by twopoint718 on Friday May 28, 2010 @07:28PM (#1387960)
There was a long post on the topic of 'regex-vs-parser' for email on reddit a while back. I hope I'm pointing to the correct person, but he wrote a parser in Haskell that validates against RFC5322: http://hackage.haskell.org/package/email-validate
Re:Perfect email regex finally found by aphyr on Friday May 28, 2010 @05:09PM (#1387666)
My comment above is a regex derived straightforwardly from the spec. Not a full parser, though.
Re:Perfect email regex finally found by alnayyir on Friday May 28, 2010 @07:15PM (#1387941)
By all means, use a CFG or a PEG for parsing emails.

While you do that, I'll do something that doesn't involve tweezers and code.