正则的坑

     match 和 excute也又这种情况, excute像是一步一步来, 结果也比match更详细, 在加g修饰符的情况下。

var str = "123#abc";  
var re = /abc/ig;  
console.log(re.test(str)); //输出ture  
console.log(re.lastIndex); //输出7  
console.log(re.test(str)); //输出false  
console.log(re.lastIndex); //输出0  
console.log(re.test(str)); //输出ture  
console.log(re.lastIndex); //输出7  
console.log(re.test(str)); //输出false  
console.log(re.lastIndex); //输出0  
原文地址:https://www.cnblogs.com/dhsz/p/7797718.html