cleanString function

String cleanString(
  1. String txt
)

Implementation

String cleanString(String txt) {
  // On moving to pty I was getting lots of escapes.

  txt = txt.replaceAll('', '');
  txt = txt.replaceAll('\r', '');

  // 20240812 gjw These seem to be in glimpse() output making the data type
  // italic. Noticed this on Anushka's Windows 10 desktop. But not on my Windows
  // 11 desktop.

  txt = txt.replaceAll('[3m[38;2;148;148;148m', '');
  txt = txt.replaceAll('[23m[m', '');

  // 20240820 gjw These were noticed on Mukund's Windows OS.

  txt = txt.replaceAll('[38;5;246m[3m', '');
  txt = txt.replaceAll('[m', '');
  txt = txt.replaceAll('[245;80H', '');

  // 20240815 gjw Generated by skimr.

  txt = txt.replaceAll('[38;5;250m', '');
  txt = txt.replaceAll('[4m', '');
  txt = txt.replaceAll('[24m', '');

  txt = txt.replaceAll('[3m[38;5;246m', '');
  txt = txt.replaceAll('[?2004l', '');
  txt = txt.replaceAll('[39m[23m', '');
  txt = txt.replaceAll('[?2004h', '');
  txt = txt.replaceAll('[A', '');
  txt = txt.replaceAll('[C', '');
  txt = txt.replaceAll('[?25h', '');
  txt = txt.replaceAll('[K', '');
  txt = txt.replaceAll(RegExp(r'\[3.m'), '');

  // 20240602 gjw Remove the `[3m[90m` that appears in the output now. Not
  // sure where that has come from or when it sneaked in.

  txt = txt.replaceAll('[3m[90m', '');

  // 20240810 Noticing these on Windows.

  txt = txt.replaceAll(RegExp(r'\[\d{1,2}[CX]'), '');

  return txt;
}