ansi-regex
Advanced tools
Comparing version 0.1.0 to 0.2.0
'use strict'; | ||
module.exports = /\x1B\[([0-9]{1,3}(;[0-9]{1,3})*)?[m|K]/g; | ||
module.exports = function () { | ||
return /\u001b\[([0-9]{1,3}(;[0-9]{1,3})*)?[m|K]/g; | ||
}; |
{ | ||
"name": "ansi-regex", | ||
"version": "0.1.0", | ||
"version": "0.2.0", | ||
"description": "Regular expression for matching ANSI escape codes", | ||
@@ -42,3 +42,7 @@ "license": "MIT", | ||
"regexp", | ||
"re" | ||
"re", | ||
"match", | ||
"test", | ||
"find", | ||
"pattern" | ||
], | ||
@@ -45,0 +49,0 @@ "devDependencies": { |
@@ -18,12 +18,17 @@ # ansi-regex [![Build Status](https://travis-ci.org/sindresorhus/ansi-regex.svg?branch=master)](https://travis-ci.org/sindresorhus/ansi-regex) | ||
ansiRegex.test('\x1b[4mcake\x1b[0m'); | ||
ansiRegex().test('\u001b[4mcake\u001b[0m'); | ||
//=> true | ||
ansiRegex.test('cake'); | ||
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](http://sindresorhus.com) |
Trivial Package
Supply chain riskPackages less than 10 lines of code are easily copied into your own project and may not warrant the additional supply chain risk of an external dependency.
Found 1 instance in 1 package
Trivial Package
Supply chain riskPackages less than 10 lines of code are easily copied into your own project and may not warrant the additional supply chain risk of an external dependency.
Found 1 instance in 1 package
1782
4
34