关于正则表达式
1、 正则表达式30分钟入门教程
http://deerchao.net/tutorials/regex/regex.htm
2、w3cschool-判断电话号码
https://www.w3cschool.cn/codecamp/validate-us-telephone-numbers.html
function telephoneCheck(str) {
// Good luck!
var reg1 = /^1? ?[1-9]{1}\d{2}[- ]?\d{3}[- ]?\d{4}$/;
var reg2 = /^1? ?\([1-9]{1}\d{2}\)[- ]?\d{3}[- ]?\d{4}$/;
return (str.match(reg1) !== null ||str.match(reg2) !== null );
}
telephoneCheck("555-555-5555");
// true
浙公网安备 33010602011771号