npm / re2js
re2js
What changed in re2js 1 to 2, from its official release notes, upgrade guides and advisories. Sources checked 2026-10-17.
2 breaking4 security12 new APIs and options6 performance4 behavior and defaults1 tooling19 fixes and other
See which of these apply to your code, ranked, in your agent:
npx @unstale/cli initre2js 239 changes
Breaking changes 2
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 2
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 6
Fixes quadratic-time behavior when LOOKBEHINDS is used with repeated-matching APIs such as matcher().find() in a loop, matchAll(), split(), and matcher().replaceAll().
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 17
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 19 changes
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 4
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.
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.