I have following code in java script
var regexp = /\$[A-Z]+[0-9]+/g;
for (var i = 0; i < 6; i++) {
if (regexp.test("$A1")) {
console.log("Matched");
}
else {
console.log("Unmatched");
}
}
Please run it on your browser console. It will print alternative Matched and Unmatched. Can anyone tell the reason for it.
After call
teston a string, thelastIndexpointer will be set after the match.and when it comes to the end, the pointer will be reset to the start of the string.
You can try ‘$A1$A1’, the result will be
This behavior is defined in 15.10.6.2, ECMAScript Language Spec.