Skip to content

Instantly share code, notes, and snippets.

@tj
Created February 2, 2012 00:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tj/1720503 to your computer and use it in GitHub Desktop.
Save tj/1720503 to your computer and use it in GitHub Desktop.
var str = 'foo bar baz'
, re = /(foo|bar|baz)/g
, captures;
while (captures = re.exec(str)) {
console.log(re.lastIndex);
console.log(captures);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment