1
0

RegexCensor.cs 446 B

123456789101112131415
  1. using System.Text.RegularExpressions;
  2. namespace Content.Shared.Chat.V2.Moderation;
  3. public sealed class RegexCensor(Regex censorInstruction) : IChatCensor
  4. {
  5. private readonly Regex _censorInstruction = censorInstruction;
  6. public bool Censor(string input, out string output, char replaceWith = '*')
  7. {
  8. output = _censorInstruction.Replace(input, replaceWith.ToString());
  9. return !string.Equals(input, output);
  10. }
  11. }