Hacker News new | ask | show | jobs
by FinnKuhn 1 day ago
I just tried this with Claude Opus 4.8 and I think it don't see any of those issues:

The first sentence is that there is no single regex that perfectly validates every technically valid email address. I think that is a good start.

It then recommends the regex used for <input type="email"> and explains that this would cover the majority of email addresses used by actual people. It also shows an improved regex that handles dot-atom local parts, quoted strings, domain names, and IPv4 domain literals, but doesn't cover things such as comments, full IPv6 literals, or internationalized addresses.

It ends with the only correct advice (in my optionion): Send a confirmation email.

1 comments

Does it say 'don't bother with a regex beyond checking it contains an @ surrounded by arbitrary pieces of text?' This still sounds like it is leading developers to conclude that they should use a too complex regex and then send a confirmation email.

Claude Sonnet says:

> A practical email regex that covers the vast majority of real-world addresses: > > ^[a-zA-Z0-9._%+\-]+@[a-zA-Z0-9.\-]+\.[a-zA-Z]{2,}$

Which is still way more complex than needed (and takes effort to read), and buggy according to years of blog posts written about this topic.

Of course the problem is the developer asking for a regex at all, but the must-regex-email instinct seems heavily engrained in our collective psyche.

I have no idea what other pay-to-play models say.