Applies RegExp.prototype.exec
iteratively. Returns array of matches.
No fancy custom return format to learn.
Example
var execAll = ; //=> [ [ 'foo', index: 0, input: 'foo bar' ],// [ 'bar', index: 4, input: 'foo bar' ] ]
Subgroups are handled just as you expect:
//=> [ [ '$200', '200', index: 0, input: '$200 and $400' ],// [ '$400', '400', index: 9, input: '$200 and $400' ] ]
API
execAll(regexp, string)
Returns array of matches in the exact format of RegExp.prototype.exec
. If regexp
is non-global, the resulting array contains either one or zero elements.
It is basically equivalent to the following snippet:
var matches = match; while match = regexp != null matches;
Install
npm install regexp.execall
License
MIT