<script>
// 1.正则表达式.test(检索的字符串) 满足true 不满足false
// [] 匹配[]中的任意字符
var reg = /^1[3-9]\d{9}$/;
var phone = "11456789011";
console.log(reg.test(phone));//false
// 2.正则表达式.exec(检索的字符串)
/*
检测通过则是返回数组 数组中包含检索通过的字符和下标以及其他信息 如果检索不到则是返回null
不加g:每次都是从下标为0的位置开始检索 检测到一个就停止
加g:从上次检索的位置开始进行查找 检索到一个就停止
注意:检索到最后为null 为null再检索是从头开始
*/
var str = "q1w2e3r4t5y6u7";
var reg = /\d/g;
console.log(reg.exec(str));//['1', index: 1, input: 'q1w2e3r4t5y6u7', groups: undefined]
console.log(reg.exec(str));//['2', index: 3, input: 'q1w2e3r4t5y6u7', groups: undefined]
console.log(reg.exec(str));//['3', index: 5, input: 'q1w2e3r4t5y6u7', groups: undefined]
console.log(reg.exec(str));//4
console.log(reg.exec(str));//5
console.log(reg.exec(str));//6
console.log(reg.exec(str));//7
console.log(reg.exec(str));//null
console.log(reg.exec(str));//1
console.log(reg.exec(str));//2
</script>