正则表达式match和lastindex疑问
var temp="HTML5 HTML5 HTML5 HTML5";
var regexp=/html5/gi;
//alert(temp.search(regexp));
var v=temp.match(regexp).length;
//alert(temp.match(regexp).length);
for (var i = 0; i < temp.match(regexp).length; i++) {
alert(regexp.test(temp));
alert(regexp.lastIndex);
}
temp.match(regexp).length 这个匹配长度是4 为什么用来作为i循环长度后 lastIndex的位置就不对了。 求大神解答一下,感谢