13 static bool ReplaceProfanities(
string input, out
string output,
string replaceChar =
"*")
15 bool profanityFound =
false;
19 output =
string.Empty;
23 if (replaceChar.IsEmpty())
26 if (replaceChar.Length() > 1)
27 replaceChar = replaceChar[0];
29 int inputLength = input.Length();
30 string inputLC = input;
32 foreach (
string profanity : s_aProfanityBlacklist)
34 int indexOf = inputLC.IndexOf(profanity);
38 profanityFound =
true;
40 int profanityLength = profanity.Length();
45 input = input.Substring(0, indexOf) + replacement + input.Substring(indexOf + profanityLength, inputLength - profanityLength - indexOf);
47 input = replacement + input.Substring(profanityLength, inputLength - profanityLength);
49 indexOf = inputLC.IndexOfFrom(indexOf + profanityLength, profanity);
54 return profanityFound;
58 protected static ref array<string> s_aProfanityBlacklist = {