4 ms·
Nice work on this! Something subtle, but I quite loved the email regex is, IMHO, close to perfect: \S+@\S+\.\S+ Because the "perfect" one is just absurd, and
by rubyn00bie 7y ago
Nice work on this!
Something subtle, but I quite loved the email regex is, IMHO, close to perfect: \S+@\S+\.\S+
Because the "perfect" one is just absurd, and no one realizes it's going to be so fucking absurd until they start getting support cases and then go read something like this: https://stackoverflow.com/a/201378/931209 https://stackoverflow.com/a/201378/931209
> If you want to get fancy and pedantic, implement a complete state engine. A regular expression can only act as a rudimentary filter. The problem with regular expressions is that telling someone that their perfectly valid e-mail address is invalid (a false positive) because your regular expression can't handle it is just rude and impolite from the user's perspective.
- p4lindromica 7y agoEven this regexp has false positives. The `ai` ccTLD ran their own mail server at the root, so an address like `a@ai` was a valid email address. They serve a website at the tld root: http://ai./ http://ai./