Regex for validating email allowing a non
I'm using RFC 5322's simplified regular expression in my application to validate any kind of possible email addresses:
[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?
But, i noticed that the string test@test.t
is valid for this regular expression (tested on RegExr):
According to IANA, none of the valid top-level domains contains only 1 character.
My real doubt is: is RFC 5322 a reliable source to get a email validation regex? May I use any other? Or test@test.t
is really valid for some specific case?
上一篇: 流星会话cookie和流星
下一篇: 正则表达式验证电子邮件允许非