this post was submitted on 03 Oct 2023
16 points (100.0% liked)
JavaScript
1982 readers
1 users here now
founded 1 year ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
The only real way to validate an email address is send it an email and see if it arrives! I'm sure many of us have fallen to the urge to validate an email with a regex though, and yes, it's just too dangerous! I definitely like the simplicity of checking for an
@
.I think regular expressions are actually very tempting to use because they seem hard. I feel like I go through this XKCD comic every time the opportunity to use a regex comes up. But string functions often have the answer. I hope, if this article achieves anything, it just stops people using regex to trim whitespace!