When you have a /g (or the /g-like looping implied by split()), the matcher tries again and again to find more matches. To avoid such infinite loops, the engine advances pos() by one character if the pattern didn't already define any advancement. This goes for empty patterns like // as well as some combination of zero-width assertions like /(?=f\w\w)(?!foo)/. The /gc variety can control this somewhat.
The "Mastering Regular Expressions" book likes to call this the 'bump along' effect: the 'transmission' bumps along the text until the pattern can succeed, or proven to fail.
-- [ e d @ h a l l e y . c c ]
|