Package Exports
- functional-regex
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (functional-regex) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Functional Regex 
Functional Regex simplifies the way you work with global regular expressions in JavaScript.
When looking for something like /foo(test)/g it's necessary to do:
var regex = /foo(test)/g,
result;
while ((result = regex.exec(test)) !== null) {
// do something with result
};
Wouldn't it be nice if we could do something more like:
var regex = /foo(test)/g;
regex.forEach(function(result) {
// do something with result.
});
And even map over the matches:
var regex = /src="([^"]*"/g;
var scripts = regex.map(function(result) {
return result[1];
});
Installation
npm install --save functional-regex
Usage
There are two ways to use Functional Regex.
- Standalone (default, because extending native prototypes is evil)
- Augmenting the RegExp prototype
1. Standalone
var fregex = require('functional-regex');
fregex.forEach(regex, text, iteratorFn);
fregex.map(regex, text, iteratorFn);
2. RegExp prototype
require('functional-regex').addToRegExp();
var regex = /foo/g;
regex.forEach(text, iteratorFn);
regex.map(text, iteratorFn);
Contributing
Open an issue, or submit a pull-request.