regexp-measure
Regular Expression Enhancements
This library exposes a RegExp
subclass to the RegExp
built-in class that extends the exec
method to return offset information for capture groups:
const RegExp2 = ; const text = "zabbcdef";const re = "ab*(cd(?<Z>ef)?)";const result = re;console; // 1console; // [0, 3, 5] // result.offsets[0] is the offset of result[0] from result.indexconst a = text;console; // abbcdef // result.offsets[1] is the offset of result[1] from result.indexconst b = text;console; // cdef // result.offsets[2] is the offset of result[2] from result.indexconst c = text;console; // ef // result.offsets.groups stores the offsets to named capture groupsconst d = text;console; // ef
API
declare