3 ms·
Use "mail.parse()" or whatever there is for your language. In general just parse stuff instead of letting some regexp loose on it. For a quick check to make su
by arp242 3y ago
Use "mail.parse()" or whatever there is for your language. In general just parse stuff instead of letting some regexp loose on it.
For a quick check to make sure people don't mix up fields or accidentally hit enter before they finished typing, just /.+@.+\..{2,}/ is more than enough (technically foo@com is valid, but no one uses that – note that root@localhost or cron@sysops CAN be valid, so in some contexts you want to use just /.+@.+/, but that doesn't really apply for signups and the like).
- swores 3y ago> "just /.+@.+\.{2,}/ is more than enough" Isn't that asking for 2x '.'s after the @, which isn't required? Should instead be /.+@.+\..+/ Which will allow foo@bar.com but not foo@bar ?
- arp242 3y agoEh yeah, I missed a dot there >_< I may be a sad case, but I don't write unit tests for my HN comments.