stripAnsi method

  1. @useResult
String stripAnsi()

Removes ANSI escape sequences (e.g. color codes) from this string.

Returns a new string with all ANSI escape sequences removed.

Example:

'\x1b[31mred\x1b[0m'.stripAnsi();  // 'red'

Implementation

@useResult
String stripAnsi() {
  if (isEmpty) return this;
  return replaceAll(_ansiEscape, '');
}