stripAnsi function
Removes ANSI escape codes from input.
Useful for calculating visible character length of styled strings.
Example:
stripAnsi('\x1B[32mGreen\x1B[0m'); // 'Green'
Implementation
String stripAnsi(String input) {
return input.replaceAll(_ansiPattern, '');
}