84669 person learning
152542 person learning
20005 person learning
5487 person learning
7821 person learning
359900 person learning
3350 person learning
180660 person learning
48569 person learning
18603 person learning
40936 person learning
1549 person learning
1183 person learning
32909 person learning
js正则表达式,不能为纯数字也不能为纯字母,必须带有数字和字母,但是不能有特殊符号。
闭关修行中......
虽然写的有点繁琐,但是的确时一个 正则实现了。
^[a-zA-Z0-9]*([a-zA-Z][0-9]|[0-9][a-zA-Z])[a-zA-Z0-9]*$
测试:
var regex = /^[a-zA-Z0-9]*([a-zA-Z][0-9]|[0-9][a-zA-Z])[a-zA-Z0-9]*$/; var arr = ['abc', '123', 'a12', '1ab', 'ab1', '12a', 'a12', '1a2', '12.a']; var result = []; arr.forEach(function(val){ result.push({ val : val, match : regex.test(val) }); }); console.table(result);
虽然写的有点繁琐,但是的确时一个 正则实现了。
测试: