Use regex, they said. It's better, they said.

Found this on Facebook.

  • 12
    I've seen a much longer one. Emails in regex are crazy if you want to cover all possibilities.
  • 5
    @jirehstudios I use one in one of my projects... a year and change in and it's still getting tweaked
  • 8
    Today regex for anything but a rough check for a @ and a . is dead.

    Before international domain names a standards compliant regex was around 4K chars long.

    With international I dont think it is possible. How does regex handle chineese?

    There are so many options that even dedicated libraries fails pn edge cases.

    Inactually dont know of a library that manages all of our testcases. But we have one that handles all but a few.
  • 9
    Just send a damn message to verify/activate... It's them who should make sure it's entered correctly.
  • 4
    You versus the guy she told you not to worry about
  • 0
    I don't really get the point of such complicated checks.

    Is it to just confirm the email was written correctly and want to avoid asking the user to enter it twice?
  • 2
    @Letmecode only way to stay current.

    Any other will probably be out of date once you get it in production ;)
  • 0
    What do you mean you found it on facebook. Do you go there when you have questions?
  • 0
    Checking for a valid email like that is pretty useless Imo. There is no definitive way to be 100% sure so sending an actual email is your best option
  • 1
    Read David Gilbertson's two-part email verification post/rant on Medium, he expailns quite well, why most email verif regexes catch only a very very small fraction of valid, but incorrect addresses
  • 0
    @rusty-hacker Someone was sharing this on a front end developer group.
  • 0
    What's the difference between checkEmailAdressForValidity and isValidEmailAdress?
Add Comment