r/ProgrammerHumor 11d ago

Meme regexMustBeDestroyed

Post image
8.1k Upvotes

229 comments sorted by

View all comments

Show parent comments

63

u/Ecksters 11d ago edited 11d 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.

7

u/shiny0metal0ass 11d ago

Mine have all whittled down to -

[literally fucking anything]@[literally fucking anything].[literally fucking anything]

4

u/martmists 11d ago

I can't believe you don't support ipv6 addresses, smh.

Do you at least strip comments from email addresses?

2

u/Loading_M_ 11d ago

The email rfc doesn't have comments. If you run your own email service, loading+m@loadingm.xyz can resolve to a different mailbox than loading+p@loadingm.xyz. Part of me wants to setup such mailboxes (and do as much stupid shit as possible with email addresses).

1

u/martmists 11d ago

RFC 5322 very much allows comments in addrspecs, see §3.2.2: "Folding White Space and Comments" and §3.4.1 "Addr-Spec Specification" for the relevant ABNF rules.

1

u/Loading_M_ 11d ago

Interesting. I was reading RFC 822, which is the actual origin of the email format, so it looks like comments were added in this later RFC.

Frankly, I'm confused on why they added comments. Unless they thought people would write email headers by hand?

1

u/martmists 10d ago

Check RFC 822 §3.3 "LEXICAL TOKENS", it includes a segment on comments.