Ohm-Management - Projektarbeit B-ME
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

readme.md 2.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. # ansi-regex [![Build Status](https://travis-ci.org/chalk/ansi-regex.svg?branch=master)](https://travis-ci.org/chalk/ansi-regex)
  2. > Regular expression for matching [ANSI escape codes](https://en.wikipedia.org/wiki/ANSI_escape_code)
  3. ---
  4. <div align="center">
  5. <b>
  6. <a href="https://tidelift.com/subscription/pkg/npm-ansi-regex?utm_source=npm-ansi-regex&utm_medium=referral&utm_campaign=readme">Get professional support for this package with a Tidelift subscription</a>
  7. </b>
  8. <br>
  9. <sub>
  10. Tidelift helps make open source sustainable for maintainers while giving companies<br>assurances about security, maintenance, and licensing for their dependencies.
  11. </sub>
  12. </div>
  13. ---
  14. ## Install
  15. ```
  16. $ npm install ansi-regex
  17. ```
  18. ## Usage
  19. ```js
  20. const ansiRegex = require('ansi-regex');
  21. ansiRegex().test('\u001B[4mcake\u001B[0m');
  22. //=> true
  23. ansiRegex().test('cake');
  24. //=> false
  25. '\u001B[4mcake\u001B[0m'.match(ansiRegex());
  26. //=> ['\u001B[4m', '\u001B[0m']
  27. '\u001B[4mcake\u001B[0m'.match(ansiRegex({onlyFirst: true}));
  28. //=> ['\u001B[4m']
  29. '\u001B]8;;https://github.com\u0007click\u001B]8;;\u0007'.match(ansiRegex());
  30. //=> ['\u001B]8;;https://github.com\u0007', '\u001B]8;;\u0007']
  31. ```
  32. ## API
  33. ### ansiRegex([options])
  34. Returns a regex for matching ANSI escape codes.
  35. #### options
  36. ##### onlyFirst
  37. Type: `boolean`<br>
  38. Default: `false` *(Matches any ANSI escape codes in a string)*
  39. Match only the first ANSI escape.
  40. ## FAQ
  41. ### Why do you test for codes not in the ECMA 48 standard?
  42. Some of the codes we run as a test are codes that we acquired finding various lists of non-standard or manufacturer specific codes. 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.
  43. 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.
  44. ## Security
  45. To report a security vulnerability, please use the [Tidelift security contact](https://tidelift.com/security). Tidelift will coordinate the fix and disclosure.
  46. ## Maintainers
  47. - [Sindre Sorhus](https://github.com/sindresorhus)
  48. - [Josh Junon](https://github.com/qix-)
  49. ## License
  50. MIT