ansi-regex provides a function that returns a regular expression for matching ANSI escape codes in strings, useful for detecting and extracting terminal formatting sequences. It can test whether a string contains ANSI codes, match all codes or only the first (via an options flag), and extract the matched escape sequences.
Project status
- Actively maintained: upstream was pushed on 2026-11-02, and updates continued through October 2026.
- Recent updates have arrived roughly every few weeks to a couple of months, though that short recent run does not establish a fixed cadence.
AI summary generated
Recent updates
v6.6.0
ansi-regex v6.6.0 fixes matching for escape sequences whose final byte is a digit and expands the sequences recognized by the regex. The implementation also changes control-string parsing and restructures the regex to handle large or incomplete inputs more safely; these details are not spelled out in the release notes.
Featuresv6.5.0
ansi-regex v6.5.0 updates ANSI escape matching to consume private-parameter CSI sequences as a whole and avoid partially stripping malformed or unsupported sequences. The implementation adds regression coverage for these cases, along with adversarial inputs.
v6.4.0
Release v6.4.0 updates ansi-regex to recognize OSC sequences that use the C1 introducer (0x9D) in addition to the traditional ESC ] introducer. The code also adjusts how OSC payload termination is detected so that unterminated C1/OSC sequences do not accidentally consume later escape sequences.
Featuresv6.3.0
Release v6.3.0 primarily updates the OSC (Operating System Command) portion of the ANSI escape code matching regex to improve performance. The release notes do not mention any behavioral differences in how OSC sequences are detected when terminators are missing or an unexpected ESC occurs.
v6.2.2
v6.2.2 is published as a follow-up release intended to fix a vulnerability reported for v6.2.1. Based on the provided diff, the only change present is a package.json version bump.
Securityv6.2.0
v6.2.0 extends ansi-regex to support colon-separated parameters in ANSI control sequences (for example, SGR 38:2 and related variants). The implementation also significantly restructures the underlying regular expression for OSC (string) and CSI (control sequence) matching.
Featuresv6.1.0
v6.1.0 updates ansi-regex to recognize additional ANSI escape sequences, including cursor save/restore, and improves OSC termination handling for all valid ST (string terminator) characters. In addition to the regex behavior changes, the release contains major packaging and TypeScript declaration changes that are not mentioned in the release notes.
Breakingv5.0.1
v5.0.1 is a backport of the ReDoS fix from v6.0.1. The release notes state it fixes CVE-2021-3807 by adjusting the ANSI escape matching regex used by the package.
Securityv6.0.1
Release v6.0.1 updates the core ANSI escape code matching regex in index.js. The release notes describe a ReDoS mitigation for CVE-2021-3807, but the code diff shows the regex logic was materially restructured rather than only tuned for performance.
Securityv6.0.0
Release v6.0.0 makes ansi-regex a pure ESM package targeting Node.js >= 12, aligning runtime, packaging, tests, and docs with ESM import syntax. The diff also includes TypeScript declaration restructuring and a package.json exports map that can change how subpath imports resolve.
Breakingv5.0.0
This release bumps the minimum supported Node.js version to 8 and introduces a TypeScript definition file for ansi-regex. The code changes also include modernized parameter handling and updated test and development tooling.
BreakingFeaturesv4.1.0
Release v4.1.0 adds improved support for additional ANSI escape codes, specifically those related to hyperlinks (links). This broadens what patterns the library can recognize compared to v4.0.0.
Features