TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

What is the most correct way to validate an e-mail address?

6 pointsby phwdover 14 years ago

3 comments

jolanover 14 years ago
PHP makes it pretty easy:<p><pre><code> if (filter_var($email, FILTER_VALIDATE_EMAIL)) { $emailvalid = 1; }</code></pre>
评论 #2098249 未加载
presidentenderover 14 years ago
I used one of those "close" regexes last time I needed to do this in C#. I believe I went with<p><pre><code> ^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.(?:[A-Z]{2,4}|museum)$</code></pre>
评论 #2103037 未加载
mike-cardwellover 14 years ago
Do not roll your own. Use a library. You will miss stuff.