ansi_regex 0.1.0 copy "ansi_regex: ^0.1.0" to clipboard
ansi_regex: ^0.1.0 copied to clipboard

Regular expression for matching ANSI escape codes.

ansi_regex #

Regular expression for matching ANSI escape codes

Install #

$ dart pub add ansi_regex

Usage #

import 'package:ansi_regex/ansi_regex.dart';

void main() {
  print(ansiRegex().hasMatch('\u001B[4mcake\u001B[0m'));
  //=> true

  print(ansiRegex().hasMatch('cake'));
  //=> false

  print(ansiRegex().allMatches('\u001B[4mcake\u001B[0m')
    .map((match) => match.group(0)));
  //=> ['\u001B[4m', '\u001B[0m']

  print(ansiRegex().allMatches('\u001B[4mcake\u001B[0m')
    .map((match) => match.group(0)));
  //=> ['\u001B[4m']

  print(ansiRegex().allMatches('\u001B]8;;https://github.com\u0007click\u001B]8;;\u0007')
    .map((match) => match.group(0)));
  //=> ['\u001B]8;;https://github.com\u0007', '\u001B]8;;\u0007']
}

0
likes
0
pub points
7%
popularity

Publisher

unverified uploader

Regular expression for matching ANSI escape codes.

Homepage
Repository (GitHub)
View/report issues

License

unknown (license)

More

Packages that depend on ansi_regex