[英]What's the problem in this regex?
var regex = /^[a-z\-A-Z_0-9]{1,}\u0040[_\-0-9a-zA-Z]{1,65}\.[a-zA-Z]{2,}$/;
document.write(regex.check("hi@email.com"));
Your code doesn't output anything, becase the check method doesn't exist in RegExp. 您的代码不输出任何内容,因为RegExp中不存在check方法。 You should use RegExp.test method 您应该使用RegExp.test方法
.{0,0}
does not match anything (ie you probably want to start with ^
and end with $
). .{0,0}
不匹配任何内容(即,您可能想以^
开头并以$
结尾)。 And you do not allow jon.bob.smith@my.domain.museum
. 而且您不允许jon.bob.smith@my.domain.museum
。 You should probably read the stackoverflow question about the best email regex . 您可能应该阅读有关最佳电子邮件正则表达式的stackoverflow问题 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.