regex-recursion

Recursive matching plugin for the `regex` package

MIT License

Downloads
88
Stars
5

Bot releases are hidden (Show)

regex-recursion - Latest Release

Published by slevithan 2 months ago

Breaking changes

  • Removed the rregex template tag previously provided as sugar. Instead of e.g. rregex`…`, import the base regex library separately and use regex({plugins: [recursion]})`…`.
  • Changed the global name in the regex-recursion.min.js browser bundle from Regex.ext to Regex.plugins.

Improvements

  • Updated documentation and tests to use the regex v4.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])}`);
}
regex-recursion -

Published by slevithan 3 months ago

  • Updated the base regex package to v3.1.0.
  • Documentation improvements.
  • Fixed an edge case where lookbehind could be mistaken for named capture.
regex-recursion - v2.0.0

Published by slevithan 4 months ago

  • Changed the capture/backreference depth suffix from $rN to _$N.
  • Fixed recursion with patterns that use atomic groups.
  • Avoids incorrect handling when recursion is used with numbered backreferences from interpolated RegExp instances, by throwing a descriptive error.
  • Fixed an issue with unnamed capturing groups when implicit flag n is disabled.
Package Rankings
Top 34.47% on Npmjs.org
Badges
Extracted from project README
build status npm bundle size