JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 201318020
  • Score
    100M100P100Q248281F
  • License MIT

Regular expression for matching ANSI escape codes

Package Exports

  • ansi-regex

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (ansi-regex) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

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']

It's a function so you can create multiple instances. Regexes with the global flag will have the .lastIndex property changed for each call to methods on the instance. Therefore reusing the instance with multiple calls will not work as expected for .test().

License

MIT © Sindre Sorhus