r/linux • • Apr 24 '11

Regular Expressions Cheat Sheet (V2)

http://www.addedbytes.com/cheat-sheets/regular-expressions-cheat-sheet/
78 Upvotes

13 comments sorted by

View all comments

Show parent comments

3

u/[deleted] Apr 24 '11
[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?

Really though, one regex for email validation is pretty thick...

3

u/broken_cogwheel Apr 24 '11

There is no perfect email validation regex. It would be better to split it up and check the portions of the address separately and be RFC compliant. If not, I'd rather accept invalid addresses rather than turn away valid ones.

w/e.

1

u/[deleted] Apr 25 '11

That is a cut and paste from RFC 2822. Unfortunately, it sucks.

2

u/geniusfreak Apr 25 '11

I see your regex, and raise you this one.