Censored.Censor.CensorText C# (CSharp) Method

CensorText() public method

Censors the text and replaces dirty words with ****
public CensorText ( string text ) : string
text string Text to censor
return string
        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;
        }