Gathering detailed insights and metrics for ansi-regex
Gathering detailed insights and metrics for ansi-regex
Gathering detailed insights and metrics for ansi-regex
Gathering detailed insights and metrics for ansi-regex
Regular expression for matching ANSI escape codes
npm install ansi-regex
Typescript
Module System
Min. Node Version
Node Version
NPM Version
99.7
Supply Chain
81.3
Quality
79
Maintenance
100
Vulnerability
100
License
JavaScript (99.04%)
TypeScript (0.96%)
Total Downloads
35,608,864,109
Last Day
14,357,073
Last Week
222,979,334
Last Month
954,964,286
Last Year
9,297,874,923
MIT License
195 Stars
57 Commits
80 Forks
16 Watchers
4 Branches
12 Contributors
Updated on Jun 27, 2025
Minified
Minified + Gzipped
Latest Version
6.1.0
Package Id
ansi-regex@6.1.0
Unpacked Size
5.29 kB
Size
2.60 kB
File Count
5
NPM Version
10.6.0
Node Version
18.20.4
Published on
Sep 09, 2024
Cumulative downloads
Total Downloads
Last Day
-2.2%
14,357,073
Compared to previous day
Last Week
-6.2%
222,979,334
Compared to previous week
Last Month
3.7%
954,964,286
Compared to previous month
Last Year
27.6%
9,297,874,923
Compared to previous year
4
Regular expression for matching ANSI escape codes
1npm install ansi-regex
1import ansiRegex from 'ansi-regex'; 2 3ansiRegex().test('\u001B[4mcake\u001B[0m'); 4//=> true 5 6ansiRegex().test('cake'); 7//=> false 8 9'\u001B[4mcake\u001B[0m'.match(ansiRegex()); 10//=> ['\u001B[4m', '\u001B[0m'] 11 12'\u001B[4mcake\u001B[0m'.match(ansiRegex({onlyFirst: true})); 13//=> ['\u001B[4m'] 14 15'\u001B]8;;https://github.com\u0007click\u001B]8;;\u0007'.match(ansiRegex()); 16//=> ['\u001B]8;;https://github.com\u0007', '\u001B]8;;\u0007']
Returns a regex for matching ANSI escape codes.
Type: object
Type: boolean
Default: false
(Matches any ANSI escape codes in a string)
Match only the first ANSI escape.
Some of the codes we run as a test are codes that we acquired finding various lists of non-standard or manufacturer specific codes. We test for both standard and non-standard codes, as most of them follow the same or similar format and can be safely matched in strings without the risk of removing actual string content. There are a few non-standard control codes that do not follow the traditional format (i.e. they end in numbers) thus forcing us to exclude them from the test because we cannot reliably match them.
On the historical side, those ECMA standards were established in the early 90's whereas the VT100, for example, was designed in the mid/late 70's. At that point in time, control codes were still pretty ungoverned and engineers used them for a multitude of things, namely to activate hardware ports that may have been proprietary. Somewhere else you see a similar 'anarchy' of codes is in the x86 architecture for processors; there are a ton of "interrupts" that can mean different things on certain brands of processors, most of which have been phased out.
7.5/10
Summary
Inefficient Regular Expression Complexity in chalk/ansi-regex
Affected Versions
>= 3.0.0, < 3.0.1
Patched Versions
3.0.1
7.5/10
Summary
Inefficient Regular Expression Complexity in chalk/ansi-regex
Affected Versions
>= 4.0.0, < 4.1.1
Patched Versions
4.1.1
7.5/10
Summary
Inefficient Regular Expression Complexity in chalk/ansi-regex
Affected Versions
>= 5.0.0, < 5.0.1
Patched Versions
5.0.1
7.5/10
Summary
Inefficient Regular Expression Complexity in chalk/ansi-regex
Affected Versions
>= 6.0.0, < 6.0.1
Patched Versions
6.0.1
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
security policy file detected
Details
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
Reason
Found 10/30 approved changesets -- score normalized to 3
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2025-06-23
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More