4 ms·
Your regex would validate: this-is-not-a-valid-address@ @this-is-not-valid-either @
by linkdd 6y ago
Your regex would validate:
this-is-not-a-valid-address@
@this-is-not-valid-either
@
- wongarsu 6y agoBut allowing too much is better than allowing too little, as usually you have to send an actual email to verify ownership anyways. Any regex more complex than /.+@.+/ fails some valid email address
- linkdd 6y agoWhich was the point of my first message.
- PeterWhittaker 6y agoSurely that should be /^[^@]+@[^@]+$/ ?
- jameshart 6y agoAccording to the RFC compliant email regex, “\@“@example.com is a valid email address, which your simplified test would reject.
- linkdd 6y agoExactly. The worst regex would be: /^[a-zA-Z0-9\-_]+@[a-zA-Z0-9\-_]+\.[a-zA-Z0-9\-_]+$/ Because it would invalidates `my-email+custom-inbox@example.com`. And that's a pattern I use to automatically sort incoming mails. Many websites use such a regex :(