sugar
Version:
A Javascript utility library for working with native objects.
16 lines (14 loc) • 344 B
JavaScript
;
function runGlobalMatch(str, reg) {
var result = [], match, lastLastIndex;
while ((match = reg.exec(str)) != null) {
if (reg.lastIndex === lastLastIndex) {
reg.lastIndex += 1;
} else {
result.push(match[0]);
}
lastLastIndex = reg.lastIndex;
}
return result;
}
module.exports = runGlobalMatch;