
外部精选
软件工程
#开发者实时流正则表达式为何拒绝含加号的邮箱地址
来源标题:Free AI for Everyone
正则表达式拒绝 name+tag@mail.com 这类含加号的邮箱地址,原因是使用了过于严格的字符匹配规则。改用否定字符类 ^[^@\s]+@[^@\s]+\.[a-z]{2,}$ 即可允许本地部分包含加号和点号。该方案同时兼容 + 和 . 字符。
Hacker News 最新Armsn2026/11/3 · 今天1 分钟阅读
这个来源的 RSS 只提供摘要,下面是原文导语;完整论述请点「打开原文」。
why does my regex reject name+tag@mail.com?
Use a negated class instead — it lets the tag through:
^[^@\s]+@[^@\s]+.[a-z]{2,}$
That also accepts + and . in the local part
Tokens stream in as Cloudy thinks — markdown, code blocks with a copy button, and a reasoning panel on the models that show their work.
本条为导读摘要,完整论述请以原文为准。