Releases: slevithan/regex
Releases · slevithan/regex
v4.2.1
v4.2.0
🚀 Features
- Added function
processRegex
, which returns an object withexpression
andflags
strings.- Warning: This feature is experimental and may change without following semver.
🐞 Fixes
- When using emulated flag x, if flag v is disabled or unsupported and
unicodeSetsPlugin
is explicitly set tonull
, allow whitespace-separated, unescaped (literal) hyphens on the end of character class ranges.
v4.1.3
v4.1.2
🚀 Features
- Added a CommonJS bundle. (#18, @subtleGradient)
- Added sourcemaps for all bundles. (#18, @subtleGradient)
v4.1.1
🚀 Features
- Combining atomic/possessive syntax with subroutines previously resulted in subroutines using capturing wrappers. This is now avoided when the regex doesn’t use backreferences, resulting in faster-running generated regex source.
- Possessive fixed repetition quantifiers (e.g.
{2}+
) are now converted to greedy quantifiers (e.g.{2}
), which gives the same behavior with faster-running generated regex source.
🐞 Fixes
- When using extended syntax (e.g. atomic groups) that resulted in the use of emulation groups in generated source, the
subclass: true
option could lead to incorrect values for submatches that preceded emulation groups, when used outside of the regex.
v4.1.0
v4.0.0
This release focused on improving and simplifying the API for advanced options and plugins. With the new features, all JavaScript-based tools that provide regex search or replace can now benefit from adopting regex
.
🚨 Breaking
- The previously experimental/debugging options
__flagX
,__flagN
,__flagV
, and__extendSyntax
have been redesigned and renamed, and are now documented features via the new optionsdisable: {x, n, v, atomic, subroutines}
andforce: {v}
. The__rake
option has been removed, and its behavior is now applied whenever flag x is enabled. - The ability to provide an alternate
RegExp
constructor by modifyingthis
has been removed. - Renamed option
postprocessors
asplugins
. - Plugins now receive flags as a property of their second argument.
🚀 Features
- New option
subclass: true
results in numbered backreferences used outside of the regex automatically referencing their correct groups, in all contexts. The underlying issue is that emulating extended syntax (atomic groups and subroutines) sometimes requires adding anonymous "emulation group" captures to generated regex source. This was already mostly a non-issue because implicit flag n requires the use of named groups. This new option makes it safe to disable n and rely on group numbers while using extended syntax. - New option
unicodeSetsPlugin
allows overriding or removing the built-in backward compatibility for environments without native support for flag v. - When using atomic groups, numbered backreferences within the regex (from interpolated regexes, or when flag n is disabled) are now supported and automatically adjusted (previously threw a descriptive error).
- Improved TypeScript types and introduced type tests, with extensive help and advice from @benblank.
- The flags provided to plugins now include the implicit v or u (whichever will be used, based on provided options and the environment's native support for v).
- The built-in backcompat layer no longer throws in the edge case of using doubly-negated
[^\P{…}]
with flag i in environments that don't natively support flag v, since the handling was incomplete and the syntax is not always problematic. New optionunicodeSetsPlugin
allows providing a more robust v transpiler, if needed.
🐞 Fixes
- Fixed backreference adjustments when atomic groups contain capturing groups.
v3.1.0
🚀 Features
- Added a browser-compatible ESM bundle, and updated
exports
to use it. - Added debugging option
__extendSyntax
, which defaults to the value of__flagN
. - Subroutines avoid adding anonymous captures for regexes that don't use backreferences.
- The token separator
(?:)
is added to emitted regex source in fewer cases.
🐞 Fixes
- Rewrote subroutine backreference handling for maintainability, and fixed some complex edge cases in the process.
- Avoids removing
(?:)
in edge cases when doing so would make an invalid regex valid.
v3.0.0
🚨 Breaking
- Renamed function/tag
partial
aspattern
.
🚀 Features
- Added support for subroutine definition groups via
(?(DEFINE)…)
at the end of a regex. - Added TypeScript declarations, and improved JSDoc-based types. (#6, @rauschma)
- Testing improvements to make tests pass with Node.js 14+.
🐞 Fixes
- Fixed an issue with interpolating a regex with numbered backreferences into a pattern with lookbehind, which could throw in edge cases.
- Fixed an issue that could allow subroutines to reference lookbehind in edge cases.
- Fixed edge case issues with subroutines that referenced groups containing backreferences to themselves.
v2.1.0
🚀 Features
- Now works in environments without native flag v support, extending compatibility from Node.js 20 to 14, and from 2023-era to 2020-era browsers (2017-era browsers with a transpilation build step).
- Postprocessors now receive the flags in use as an argument.