public string CensorText(string text)
{
if (string.IsNullOrWhiteSpace(text))
return text;
var censoredText = text;
foreach (string censoredWord in CensoredWords)
{
var regularExpression = ToRegexPattern(censoredWord);
censoredText = Regex.Replace(censoredText, regularExpression, StarCensoredMatch,
RegexOptions.IgnoreCase | RegexOptions.CultureInvariant);
}
return censoredText;
}