npm / re2js
re2js
What changed in re2js 1 to 2, from its official release notes, upgrade guides and advisories. Sources checked 2026-11-30.
5 breaking6 security13 new APIs and options5 performance4 behavior and defaults1 tooling21 fixes and other
See which of these apply to your code, ranked, in your agent:
npx @unstale/cli initre2js 243 changes
Breaking changes 3
Only Unicode groups are accepted.
Pass true for the new javaMode flag to opt into the previous Java-style escaping and invalid capture group exceptions.
replaceAll and replaceFirst now use native ECMAScript replacement semantics by default: $$ escapes a dollar sign, and backslash is treated literally.
Security 4
Additional checks are performed for inputs.
Fixes quadratic-time behavior when LOOKBEHINDS is used with repeated-matching APIs such as matcher().find() in a loop, matchAll(), split(), and matcher().replaceAll().
Includes small security fixes.
Fixed prototype pollution in getNamedGroups.
New APIs and options 8
Adds a new exec method.
RE2Set now supports customizing its memory limit.
Supports more Unicode categories, including Emoji, Emoji_Component, Emoji_Modifier, and ASCII_Hex_Digit.
replaceAll() now accepts a function as replacement in addition to a string.
replaceFirst() now accepts a function as replacement in addition to a string.
Added the matchAll method.
Added a tagged template literal method for constructing regular expressions.
RE2 lookbehinds are supported.
Performance 5
Removes O(n) array copying during UTF-8 encoding.
Optimizes the per-byte spawning loop for the LOOKBEHINDS flag.
Word boundaries are faster.
Added an Aho-Corasick prefilter.
Performance improvements for DFA may improve regular expression execution speed.
Behavior and default changes 4
translateRegExp() now supports native Regex.
DFA cache eviction is now granular.
The Unicode mapping is updated to version 17.
Improves the RE2Set feature.
Fixes and other changes 19
Fixes the type declaration for the re method after an issue introduced by the TypeScript 7 update.
The DFA now handles \b, \B, ^, $, \A and \z itself.
Fixes bugs in replace.
Fixes bugs in split.
Fixes the types for resetMatcherInput.
Fixes polymorphic inputs to resetMatcherInput.
Fixes TypeScript types for more methods.
Adds AST SyntaxError validation for the LOOKBEHINDS flag, helping identify invalid syntax.
Fixed a desynchronization bug in matchAll.
Fixes Unicode case folding across all JavaScript environments.
Fixes were made to the TypeScript declaration files.
TypeScript type fixes were made.
Fixes were made to translateRegExp().
Unicode fixes may change how regular expressions handle Unicode.
Fixes issues that cause “Maximum call stack size exceeded.”
Fixed a compiler memory leak.
Fixed onepass logic.
Zero-width matches no longer corrupt UTF-8 or UTF-16.
The RE2Set flags interface is fixed.
re2js 112 changes
Breaking changes 2
Escape parsing supports only ASCII values and reports an error for invalid escapes in a regex.
Adds parse-tree checks for regex height, runes and size so oversized or deeply nested regexes raise the same errors as original re2.
Security 2
Fixes information disclosure and XSS in Matcher.quoteReplacement.
Instance and static matches() methods use the testExact() DFA fast-path, providing a significant performance boost and ReDoS immunity.
New APIs and options 5
Adds high-performance boolean testing with test(), offering a faster alternative to matcher.find() for checking whether a pattern matches.
Adds a high-performance boolean testing method for exact matching.
Introduced lazy DFA.
Adds a Matcher export for TypeScript consumers.
Adds a method that provides a very approximate measure of a regexp's cost; larger values indicate more expensive regexps.
Tooling 1
TypeScript support was improved.
Fixes and other changes 2
The return type of end was fixed.
The return type of start was fixed.