Package Exports
- regexp-match-indices
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 (regexp-match-indices) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
regexp-match-indices
This package provides a polyfill/shim for the RegExp Match Indices proposal.
The implementation is a replacement for RegExp.prototype.exec
that approximates the beahvior of the proposal. Because RegExp.prototype.exec
depends on a receiver (the this
value), the main export accepts the RegExp
to operate on as the first argument.
Installation
npm install regexp-match-indices
Usage
Standalone
const execWithIndices = require("regexp-match-indices");
const text = "zabbcdef";
const re = new RegExp("ab*(cd(?<Z>ef)?)");
const result = execWithIndices(re, text);
console.log(result.indices); // [[1, 8], [4, 8], [6, 8]]
Shim
require("regexp-match-indices").shim();
// or
require("regexp-match-indices/shim")();
// or
require("regexp-match-indices/auto");
const text = "zabbcdef";
const re = new RegExp("ab*(cd(?<Z>ef)?)");
const result = re.exec(re, text);
console.log(result.indices); // [[1, 8], [4, 8], [6, 8]]