AnsiToHtml.cs 373 B

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