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.

123456789101112131415161718192021222324252627282930313233
  1. export interface Options {
  2. /**
  3. Match only the first ANSI escape.
  4. @default false
  5. */
  6. readonly onlyFirst: boolean;
  7. }
  8. /**
  9. Regular expression for matching ANSI escape codes.
  10. @example
  11. ```
  12. import ansiRegex from 'ansi-regex';
  13. ansiRegex().test('\u001B[4mcake\u001B[0m');
  14. //=> true
  15. ansiRegex().test('cake');
  16. //=> false
  17. '\u001B[4mcake\u001B[0m'.match(ansiRegex());
  18. //=> ['\u001B[4m', '\u001B[0m']
  19. '\u001B[4mcake\u001B[0m'.match(ansiRegex({onlyFirst: true}));
  20. //=> ['\u001B[4m']
  21. '\u001B]8;;https://github.com\u0007click\u001B]8;;\u0007'.match(ansiRegex());
  22. //=> ['\u001B]8;;https://github.com\u0007', '\u001B]8;;\u0007']
  23. ```
  24. */
  25. export default function ansiRegex(options?: Options): RegExp;