Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
That email REGEX is not going to allow some domain extension like .solutions for example 🤷♂️
-
rantydev2963y@PappyHans it will, won't it? It needs at least two characters after the last period; but any amount would do right?
-
Hazarth95213y@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 -
rantydev2963y@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
-
hitko31453y@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.
-
@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. -
@IntrusionCM exactly. Allow anything with an @ in it, then send it a confirmation email. If confirmed it's a valid email.
Related Rants
joke/meme
regex