-
Notifications
You must be signed in to change notification settings - Fork 4
/
util.js
26 lines (25 loc) · 882 Bytes
/
util.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
/**
* [[Description]]
* @param {[[Type]]} function (require [[Description]]
* @param {Object} exports [[Description]]
* @param {[[Type]]} module [[Description]]
* @returns {[[Type]]} [[Description]]
*/
define(function (require, exports, module) {
"use strict";
/**
* Utility function for matching all instances of a regular expression in a string
* @param regex the regular expression to apply
* @param string the string to apply the regular expression on
* returns Array<> an array of matches along with the index of occurence in the string
*/
function _matchAll(regex, string) {
var res = [], m = regex.exec(string);
while (m) {
res.push({index: m.index, matches: m});
m = regex.exec(string);
}
return res;
}
exports.matchAll = _matchAll;
});