Quote:
|
As with exec (or in combination with it), test called multiple times on the same global regular expression instance will advance past the previous match.
|
Mozilla
Code:
regexPattern = new RegExp("a","gi");
s = "a";
alert (regexPattern.test(s));//--> true
alert(regexPattern.lastIndex); // 1
alert (regexPattern.test(s));//--> false
alert(regexPattern.lastIndex); // 0
alert (regexPattern.test(s));//--> true
alert(regexPattern.lastIndex); // 1
alert (regexPattern.test(s));//--> false
alert(regexPattern.lastIndex); // 0