AnsiToHtml.cs 372 B

123456789101112131415
  1. using System.Text.RegularExpressions;
  2. namespace Shared.Rcl;
  3. public static class AnsiStripper {
  4. private static readonly Regex _csiRegex =
  5. new(@"\x1B\[[0-9;?]*[A-Za-z]", RegexOptions.Compiled);
  6. public static string Strip(string input) {
  7. if (string.IsNullOrEmpty(input))
  8. return "";
  9. return _csiRegex.Replace(input, "");
  10. }
  11. }