Back to Explore

chalk/ansi-regex

GitHub
1 watchersOpen source

Last release: 9 months ago

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

AI-generated from public sources. May be inaccurate. Report

Recent updates

  • v6.2.2

    9 months ago

    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.

    Security
  • v6.2.0

    9 months ago

    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.

    Features
  • v6.1.0

    9/9/2024

    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.

    Breaking
  • v5.0.1

    9/14/2021

    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.

    Security
  • v6.0.1

    9/10/2021

    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.

    Security
  • v6.0.0

    4/16/2021

    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.

    Breaking
  • v5.0.0

    10/4/2019

    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.

    BreakingFeatures
  • v4.1.0

    3/8/2019

    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