Last change
on this file since 6a3a178 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
1.7 KB
|
Line | |
---|
1 | # ansi-regex [![Build Status](https://travis-ci.org/chalk/ansi-regex.svg?branch=master)](https://travis-ci.org/chalk/ansi-regex)
|
---|
2 |
|
---|
3 | > Regular expression for matching [ANSI escape codes](http://en.wikipedia.org/wiki/ANSI_escape_code)
|
---|
4 |
|
---|
5 |
|
---|
6 | ## Install
|
---|
7 |
|
---|
8 | ```
|
---|
9 | $ npm install --save ansi-regex
|
---|
10 | ```
|
---|
11 |
|
---|
12 |
|
---|
13 | ## Usage
|
---|
14 |
|
---|
15 | ```js
|
---|
16 | const ansiRegex = require('ansi-regex');
|
---|
17 |
|
---|
18 | ansiRegex().test('\u001b[4mcake\u001b[0m');
|
---|
19 | //=> true
|
---|
20 |
|
---|
21 | ansiRegex().test('cake');
|
---|
22 | //=> false
|
---|
23 |
|
---|
24 | '\u001b[4mcake\u001b[0m'.match(ansiRegex());
|
---|
25 | //=> ['\u001b[4m', '\u001b[0m']
|
---|
26 | ```
|
---|
27 |
|
---|
28 | ## FAQ
|
---|
29 |
|
---|
30 | ### Why do you test for codes not in the ECMA 48 standard?
|
---|
31 |
|
---|
32 | Some of the codes we run as a test are codes that we acquired finding various lists of non-standard or manufacturer specific codes. If I recall correctly, 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.
|
---|
33 |
|
---|
34 | 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.
|
---|
35 |
|
---|
36 |
|
---|
37 | ## License
|
---|
38 |
|
---|
39 | MIT © [Sindre Sorhus](http://sindresorhus.com)
|
---|
Note:
See
TracBrowser
for help on using the repository browser.