<script type="text/javascript">
var ps = "[A-Za-z]\\w{3,}@\\w{2,}(\\.\\w{2,})+"
var p = new RegExp("^" + ps + "(;" + ps + ")*$")
var s = "[email protected]";
alert(p.test(s));
</script>
var ps = "[A-Za-z]\\w{3,}@\\w{2,}(\\.\\w{2,})+"
var p = new RegExp("^" + ps + "(;" + ps + ")*$")
var s = "[email protected]";
alert(p.test(s));
</script>
解决方案 »
- 非常诡异的 正则表达式 失效问题..... A-Z 可以匹配小写字母, 求助...
- jQuery change 事件触发后判断修改的值是否合法,不合法返回原值
- js刷新问题
- (求助) IE与Firefox 正则表达式 兼容问题
- 填写表单时按回车可以换行
- showModelessDialog窗口彈出問題(help)
- 求页面浮动的广告图片的代码
- 如何通过选择按钮改变form的action值?(要求用客户端javascript)
- 如何用javascript写注册表
- 请问有没有办法检测来路链接是否为伪造?
- 如何实现页面在没有鼠标点击或键盘键入一定时间内自动关闭
- frame与iframe的刷新问题,大虾们帮帮忙
var ps = "[A-Za-z]\\w{3,}@\\w{2,}(\\.\\w{2,})+";
var p = new RegExp("^" + ps + "(;" + ps + ")*$");
var s = "[email protected]"; //[email protected];[email protected]...
var boolean = p.test(s);
alert(boolean);
</script>
我是想批量检测,所以要用到split分割成数组,然后要循环遍历一次.
function checkEmail(s) {
var ps = "[A-Za-z]\\w{3,}@\\w{2,}(\\.\\w{2,})+";
var p = new RegExp("^" + ps + "(;" + ps + ")*$");
if (p.test(s)) {
var t = new RegExp("(" + ps + ");?", "g");
var temp = ";";
s = s.replace(t, function (a, b) {
if (temp.indexOf(";" + b + ";") == -1) {
temp += b + ";";
return b + ";";
} else return "";
});
return s.substring(0, s.length - 1);
} else return false;
}
var s = "[email protected];[email protected];[email protected];[email protected];[email protected]";
if (s = checkEmail(s)) alert(s);
else alert("箱子错误");
</script>
这个可以替换掉重复的箱子。
muxrwc(王辰),li1229363() ,fqcd555(Oo等待你oO)建议都不错..谢谢了