I might have something better. Certainly more suited to my needs:
Tests are at http://sourceforge.net/p/verbosio/te...kenIterator.js
The commit message says it best: "Implement a quick & dirty 'TokenIterator' class for fast string searching, and skipping over substrings we don't care about."
Yours does go character by character, so with just-in-time compilation it might run faster than my code. A few comments would've been helpful. (Also, because I use Map(), a hashtable for JS that isn't available in IE yet, mine's not cross-platform.)