Skip to content

Instantly share code, notes, and snippets.

@elclanrs
elclanrs / gmatch.js
Last active December 16, 2015 22:20
/**
* String.prototype.gmatch
*/
String.prototype.gmatch = function(regex) {
var result = [];
this.replace(regex, function() {
var matches = [].slice.call(arguments, 1, -2);
result.push.apply(result, matches);
});
return result;