37
Comments
  • 13
    That email REGEX is not going to allow some domain extension like .solutions for example 🤷‍♂️
  • 0
    @PappyHans it will, won't it? It needs at least two characters after the last period; but any amount would do right?
  • 8
    @rantydev it says {2,4} so it takes any word characters 2-4 times and then expects the end of the line

    I think Pappy is right
  • 1
    @Hazarth ah right! I was thinking that the group before could include any character or period, but no it has to end with a period. You are right
  • 7
    You don't validate emails.

    As simple as that.
  • 1
    I can’t remember which movie this is
  • 1
  • 2
    @PappyHans It also won't allow subdomains, nor symbols in username, nor addresses with IP instead of a domain name, nor escaped characters, ... Email address falls under context-free (or maybe even context-sensitive) grammar, which can't be expressed as a regular expression.
  • 0
    @tonypolik god I hated that movie lol
  • 2
    @catgirldev that's the sanest choice, simple substr check.

    In general (to elaborate further, not as a reply to you specifically).

    Most email validations are plain wrong and even an security issue (e.g. regex backtracking).

    The first goal in validation should be: Do no harm.

    What can mostly be found on craptastic sites like ShitOverflow is the exact opposite of that.

    Additional to the issue of security / performance - mail address validation is doomed to fail because mail is one of most obscure and insane raped and mutilated standards.

    Mail to an IP address? Yup. Possible.

    Mail to an mail address with case sensitive? Yup. Possible.

    Mail to an mail address with umlauts / UTF-8? Yup. Possible.

    So keep it simple. After all, the worst that can happen is that the client gets no mail via the written address - which can happen in any case, as the client can mistype.

    Do no harm - don't validate for obscure reasons, especially not if it leads to security / performance issues.
  • 0
    That email regex does not support aliases nor non ASCII characters
  • 1
    @IntrusionCM exactly. Allow anything with an @ in it, then send it a confirmation email. If confirmed it's a valid email.
Add Comment