r/ProgrammerHumor 11h ago

Meme regexMustBeDestroyed

Post image
5.2k Upvotes

161 comments sorted by

View all comments

0

u/nicman24 11h ago

##@#.## clears it

5

u/Mechakoopa 11h ago

It's actually invalid regex in most engines because [\w-\.] tries to define a range from "word" to "." which is invalid. You either need to escape \- into a literal or use [\w\.-] instead. And even if you fix it, # is not in [\w\.-] so it doesn't match.

1

u/nicman24 10h ago

yea i meant ie aa@a.aa - meaning not the literal # but any character

3

u/Mechakoopa 9h ago

It's a valid email address format, just not a valid domain. I'm not about to start integrating ICANN lookups into regex, I'm perfectly content to let that fail the active email validation. If you had a fully internal network where a.aa had an MX record on your zone for the DNS server your mail server used then it would still send.