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
- The repository appears actively maintained, with a recent upstream push on 2026-02-18 and multiple versioned updates in 2025 (v6.2.0, v6.2.2).
- The apparent update cadence is intermittent rather than frequent, with a major functional update in 2025-08 (v6.2.0), a follow-up patch in 2025-09 (v6.2.2, intended to address a vulnerability in v6.2.1), and the next earlier major update in 2024-09 (v6.1.0).
AI summary generated Today
Recent updates
v6.2.2
9 months agov6.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
9 months agov6.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
9/9/2024v6.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
9/14/2021v5.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
9/10/2021Release 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
4/16/2021Release 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
10/4/2019This 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
3/8/2019Release 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