node-query/node_modules/grunt-istanbul/node_modules/chalk/node_modules/strip-ansi/node_modules/ansi-regex
Timothy Warren ba6b3c311d Update included modules 2015-01-28 15:33:44 -05:00
..
index.js Update included modules 2015-01-28 15:33:44 -05:00
package.json Update included modules 2015-01-28 15:33:44 -05:00
readme.md Update included modules 2015-01-28 15:33:44 -05:00

readme.md

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