Socket
Socket
Sign inDemoInstall

ansi-regex

Package Overview
Dependencies
0
Maintainers
2
Versions
17
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

ansi-regex

Regular expression for matching ANSI escape codes


Version published
Maintainers
2
Weekly downloads
145,663,500
decreased by-8.14%

Weekly downloads

Package description

What is ansi-regex?

The ansi-regex npm package is used to create regular expressions to match ANSI escape codes, which are used to format output in terminal with colors, background colors, styles like bold or underline, and other text effects.

What are ansi-regex's main functionalities?

Matching ANSI escape codes

This code sample demonstrates how to use ansi-regex to match ANSI escape codes in a string. The string contains the ANSI escape codes for underlining text, followed by the word 'cake', and then the reset code to stop the underlining. The ansiRegex function is called to generate a regular expression that matches these codes.

"\u001B[4mcake\u001B[0m".match(ansiRegex());

Other packages similar to ansi-regex

Readme

Source

ansi-regex Build Status

Regular expression for matching ANSI escape codes

Install

$ npm install --save ansi-regex

Usage

var ansiRegex = require('ansi-regex');

ansiRegex().test('\u001b[4mcake\u001b[0m');
//=> true

ansiRegex().test('cake');
//=> false

'\u001b[4mcake\u001b[0m'.match(ansiRegex());
//=> ['\u001b[4m', '\u001b[0m']

License

MIT © Sindre Sorhus

Keywords

FAQs

Last updated on 30 Jun 2015

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc