Skip to content

Instantly share code, notes, and snippets.

@luishendrix92
Last active February 20, 2017 06:13
Show Gist options
  • Save luishendrix92/773f1eb395f266549a816c927b7430ee to your computer and use it in GitHub Desktop.
Save luishendrix92/773f1eb395f266549a816c927b7430ee to your computer and use it in GitHub Desktop.
JavaScript RegExp Scan Polyfill
RegExp.prototype.scan = function(text) {
var result = [], match;
while(match = this.exec(text)) {
result.push(match);
}
return result;
};
// Note, you can coerce RegExp to a String
// and this function will hang if there's no global flag.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment