When a regex is used with the g operator in JavaScript, it keeps
track of where the last match was found for future use. When a new
test is ran on that same regex, the pattern continues searching
from the lastIndex which means patterns before the lastIndex are not
used when testing. This can result in strings that should have matched
the regex to be reported as not matching.
Adds a line to reset the lastIndex of pseudos to zero before each
test is ran to make sure all patterns are tested against every single
time.
Additional information about the problem can be found at:
When a regex is used with the g operator in JavaScript, it keeps track of where the last match was found for future use. When a new test is ran on that same regex, the pattern continues searching from the lastIndex which means patterns before the lastIndex are not used when testing. This can result in strings that should have matched the regex to be reported as not matching.
Adds a line to reset the lastIndex of pseudos to zero before each test is ran to make sure all patterns are tested against every single time.
Additional information about the problem can be found at:
http://blog.stevenlevithan.com/archives/fixing-javascript-regexp