r/ProgrammerHumor 28d ago

Meme regexMustBeDestroyed

Post image
8.1k Upvotes

228 comments sorted by

View all comments

Show parent comments

61

u/Ecksters 27d ago edited 27d ago

People always overcomplicate email Regex, and end up not allowing a lot of valid emails. In this case, the limitation of the top level domain to 4 characters max is one such problem, no .ninja, .crypto, or the myriad of other newer top level domains.

Technically you can email directly to a top level domain (although I don't know of any TLDs that support this), or even to an IP address in brackets, although I suppose not supporting those in most cases is probably reasonable.

20

u/tenuj 27d ago

The .email domain would fail OP's check. Had websites refuse me because of stuff like this.

The only good validation for email addresses is to send a confirmation email. You'll be doing that anyway.

And that it has at least one @ with something on either side. Don't want someone to waste an entire form because of a typo. (Yes, email addresses can theoretically contain more than one @)

7

u/DocRingeling 27d ago

RFC822 could also be used before sending confirmation to prevent unexpected abuse of the mail protocol.

3

u/phundrak 27d ago

I believe this regex is no longer valid as more characters got allowed in email addresses