TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Email Address Regular Expression That 99.99% Works

16 点作者 arun-mani-j超过 1 年前

11 条评论

Etheryte超过 1 年前
Yeah no, if you try to check this into any codebase it should get rejected straight away. There is no need to regex emails pretty much anywhere, when you use an email for signup or similar you send a confirmation email which serves the same purpose - to make sure the address is valid and correct. Use `<input type="email">` or check that "@" is present if you must, but anything beyond that is nonsense.
评论 #37996949 未加载
tiborsaas超过 1 年前
Don&#x27;t use a regex, test only for a @ and a dot after it and call it a day.<p>Btw content is unreadable thanks to aggressive adblocker detection so much that this feels like spam.
评论 #37996920 未加载
evrimoztamur超过 1 年前
Each time that this or its variants get posted here, the response is the same:<p>Check if there’s an @ and send a verification email.
Retr0id超过 1 年前
Archived: <a href="https:&#x2F;&#x2F;web.archive.org&#x2F;web&#x2F;20231024092745&#x2F;https:&#x2F;&#x2F;emailregex.com&#x2F;index.html" rel="nofollow noreferrer">https:&#x2F;&#x2F;web.archive.org&#x2F;web&#x2F;20231024092745&#x2F;https:&#x2F;&#x2F;emailrege...</a>
评论 #37996892 未加载
a9ex超过 1 年前
I usually just test for the presence of @ - that’s it. Works for IDN addresses as well.<p>I remember some story back in the day where someone had an email address using the top level to domain only. Like “x@to”, pretty cool but probably a pain to use (:
creshal超过 1 年前
Why does this site need an adblocker-blocker?
arp242超过 1 年前
Use &quot;mail.parse()&quot; or whatever there is for your language. In general just parse stuff instead of letting some regexp loose on it.<p>For a quick check to make sure people don&#x27;t mix up fields or accidentally hit enter before they finished typing, just &#x2F;.+@.+\..{2,}&#x2F; is more than enough (technically foo@com is valid, but no one uses that – note that root@localhost or cron@sysops CAN be valid, so in some contexts you want to use just &#x2F;.+@.+&#x2F;, but that doesn&#x27;t really apply for signups and the like).
评论 #37996983 未加载
mmh0000超过 1 年前
This[1] is or at least, was PHPs validator for email. Author provides a lot of insight into the complexity of regexing emails.<p>[1] <a href="https:&#x2F;&#x2F;fightingforalostcause.net&#x2F;content&#x2F;misc&#x2F;2006&#x2F;compare-email-regex.php" rel="nofollow noreferrer">https:&#x2F;&#x2F;fightingforalostcause.net&#x2F;content&#x2F;misc&#x2F;2006&#x2F;compare-...</a>
arun-mani-j超过 1 年前
I have uBlock Origin and it works fine in my Firefox.<p>Sorry I didn&#x27;t knew of this adblock detection nonsense, otherwise wouldn&#x27;t have posted it. :(
MilStdJunkie超过 1 年前
Why would you <i>do</i> this?! Mail parse libraries are <i>everywhere</i>
sam_lowry_超过 1 年前
The first thing I tried, root@localhost, did not match ;&#x2F;