var pattern = /y/g; pattern.lastIndex = 3; var match = pattern.exec("xyzzy"); console.log(match.index); // → 4 console.log(pattern.lastIndex); // → 5
I believe we are trying to match the for the pattern /y/g. Does g here mean global?
So if lastIndex = 3, we will be starting at the 3 point. Which would be "z"? So we are looking for the "y" after the second "z"? Is this correct?
I do not understand what line 6 is doing.
Thank you for your time. Any help is appreciated.
Submitted July 15, 2017 at 08:26PM by NewbiusCoder
via reddit http://ift.tt/2v58vOT