I have a question that" it is the error or i missing something ?" I'm learning Regex in javascript and got brower crash when trying to do this code:
function myFunction() {
var str = "100, 1000 or 10000?";
var patt1 = /\d{4}/g;
while(patt1.test(str)==true){
console.log(patt1.lastIndex);
console.log(string.match(patt1));
}
}
i guess that match method reset the index back to 0 because lastIndex always is 9, but i don't know how to these method work step by step. please help me solve step by step .Thank you so much!