简体   繁体   English

电子邮件的Javascript正则表达式(不包括“ [”和“]”)

[英]Javascript regex for email excluding '[' and ']'

I am trying to make regex for email my regex is: 我正在尝试通过电子邮件发送正则表达式,而我的正则表达式是:

^(?:[0-9a-zA-z.!!@#$%^&*+={}'/-]+@[a-zA-Z]{1}[a-zA-Z]+[/.][a-zA-Z]{2,4}|)$

According to this regex it should accept special characters as mentioned in rule but sholud not accept [ and ] but it accepting [ and ] 根据此正则表达式,它应接受规则中提到的特殊字符,但不接受[]但应接受[]

I want to use this regex but it should exclude [ and ] 我想使用此正则表达式,但应排除[]

How can I do that? 我怎样才能做到这一点?

If you want validate email, then regular expression will be look like this: 如果要验证电子邮件,则正则表达式将如下所示:

^(?:[0-9a-zA-z.]+@[a-zA-Z]{2,}[/.][a-zA-Z]{2,4}|)$

正则表达式可视化

Debuggex Demo Debuggex演示

But it very simplified. 但是它非常简化。 Full version here http://www.ex-parrot.com/pdw/Mail-RFC822-Address.html 完整版本在这里http://www.ex-parrot.com/pdw/Mail-RFC822-Address.html

UPD: Just typo in original regular expression Az -> AZ UPD:原始正则表达式Az > AZ拼写错误

^(?:[0-9a-zA-Z\.!@#$%^&*+={}'/-]+@[a-zA-Z]{1}[a-zA-Z]+[/.][a-zA-Z]{2,4}|)$

正则表达式可视化

Debuggex Demo Debuggex演示

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM