I'm creating a sort of filter for a message, but running into some trouble with actually replacing parts of the word.
After looking over this question, I tried to do it almost exactly like they did. However, I want to work with multiple possible words to filter, and I want each to have a different thing to change to. A dictionary would seem to work perfectly for this. However, it does not work.
Dictionary<string, string> filterWords = new Dictionary<string, string>
{
{"lol", "LAUGH OUT LOUD"},
{"wtf", "WOW THAT'S FANTASTIC"},
};
foreach (KeyValuePair<string, string> word in filterWords)
{
Regex r = new Regex(@"\b" + word.Key + "\b");
message = r.Replace(message, word.Value);
}
I don't see anything really wrong with the code, but it doesn't actually replace any words, and I'm stumped as to how to fix it.