Releases: slevithan/regex-recursion
Releases · slevithan/regex-recursion
v4.0.0
Breaking changes
- Removed the
rregextemplate tag previously provided as sugar. Instead of e.g.rregex`…`, import the baseregexlibrary separately and useregex({plugins: [recursion]})`…`. - Changed the global name in the
regex-recursion.min.jsbrowser bundle fromRegex.exttoRegex.plugins.
Improvements
- Updated documentation and tests to use the
regexv4.0.0 plugin API.
Fixes
- Fixed a syntax error when using a named backreference within recursion that references a group outside of the recursive subpattern.
If desired, you can recreate the rregex tag from previous versions:
import {regex} from 'regex';
import {recursion} from 'regex-recursion';
function rregex(first, ...values) {
const plugins = (first?.plugins || []).concat(recursion);
// Given a template
if (Array.isArray(first?.raw)) {
return regex({plugins})(first, ...values);
// Given flags
} else if ((typeof first === 'string' || first === undefined) && !values.length) {
return regex({flags: first, plugins});
// Given an options object
} else if ({}.toString.call(first) === '[object Object]' && !values.length) {
return regex({...first, plugins});
}
throw new Error(`Unexpected arguments: ${JSON.stringify([first, ...values])}`);
}v3.1.0
v2.0.0
- Changed the capture/backreference depth suffix from
$rNto_$N. - Fixed recursion with patterns that use atomic groups.
- Avoids incorrect handling when recursion is used with numbered backreferences from interpolated
RegExpinstances, by throwing a descriptive error. - Fixed an issue with unnamed capturing groups when implicit flag
nis disabled.