Email Validation Regex

Discussions criticize using regex for email address validation due to its complexity and edge cases, advocating simpler checks like presence of '@' or sending confirmation emails instead.

📉 Falling 0.2x Web Development
2,666
Comments
19
Years Active
5
Top Authors
#4716
Topic ID

Activity Over Time

2007
3
2008
29
2009
47
2010
120
2011
91
2012
240
2013
373
2014
76
2015
123
2016
263
2017
89
2018
142
2019
96
2020
152
2021
216
2022
264
2023
142
2024
110
2025
90

Keywords

e.g JS OK APL domain.tld Mailcheck.js OT HN XML example.com email email address address regex email addresses validate addresses validation valid invalid

Sample Comments

jammi May 26, 2013 View on HN

No, don't validate email addresses with regex. It's more complex than that.

eik3_de Feb 26, 2014 View on HN

they don't even check if the email looks right. [email protected] works..

edblarney Nov 16, 2016 View on HN

The issue is not regexing, it's lack of real standard in email format :)

Avamander Dec 17, 2019 View on HN

Just... don't try to validate it like that. Check if you can send an e-mail to it, if you can then it's fine. I see way too many devs thinking they can validate e-mails with regex and then I can't use my own name in my e-mail.

Etheryte Oct 24, 2023 View on HN

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 `` or check that "@" is present if you must, but anything beyond that is nonsense.

nulltype Mar 26, 2015 View on HN

How do you validate email addresses properly?

roryisok Jul 28, 2018 View on HN

This is why people should write proper code to parse and validate email addresses and not use regex

ketralnis Apr 3, 2016 View on HN

Yes there are loads of invalid email addresses it allows. It's not supposed to be perfect.

dan1234 Aug 18, 2016 View on HN

I was thinking of using this as the basis for some email validation as I got a lot of incorrect email addresses in form posts.

montecarl May 24, 2013 View on HN

Why not have a simple validator that works with 99% of users emails but not make it mandatory that it passes validation?"We see that bob@localhost doesn't look like a email address are you sure it's right?"That way you can help users that messed up their email but not prevent all the corner cases. The idea is that most email addresses fall in a very narrow subset of the RFC: [email protected] and most people would have entered their email wrong if it didn't match that pattern.