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

Regular expression for matching ANSI escape codes.

example/ansi_regex_example.dart

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
120
pub points
5%
popularity

Publisher

unverified uploader

Regular expression for matching ANSI escape codes.

Homepage
Repository (GitHub)
View/report issues

Documentation

API reference

License

Apache-2.0 (LICENSE)

More

Packages that depend on ansi_regex