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, with the upstream repository having pushed changes on 2026-08-12 and the latest published update (v6.3.0 on 2026-08-12) following immediately, suggesting an active maintenance workflow.
- Apparent update cadence is irregular but currently active, with major updates in 2024 to 2025 (v6.1.0 in 2024-09, v6.2.0 in 2025-08, v6.2.2 in 2025-09) and a new update again in 2026-08, after about a 11-month gap.
AI summary generated
Recent updates
v6.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