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.
Activity Over Time
Top Contributors
Keywords
Sample Comments
No, don't validate email addresses with regex. It's more complex than that.
they don't even check if the email looks right. [email protected] works..
The issue is not regexing, it's lack of real standard in email format :)
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.
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.
How do you validate email addresses properly?
This is why people should write proper code to parse and validate email addresses and not use regex
Yes there are loads of invalid email addresses it allows. It's not supposed to be perfect.
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.
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.