Port some ideas Russ Cox (@rsc) shared on how Google Code Search works (http://swtch.com/~rsc/regexp/regexp4.html) to JavaScript