So, I have the code, and I refined it so that it works as best as possible. Now it works fine, although I need to filter it throughout the sentence, regardless of any special characters wrapped around the word. For example, when I send a line:
JOIN GooGle | Γ ,,. Β¬ hiring !HOteL, it is ++ !!free!! ,, ..!community;;+_
Prohibited words join, hiring, hotel, free, communitywill not define the sentence above.
My code is:
public bool CheckSentence(string messageText.ToLower())
{
var count = 0;
string[] wordsInMessage = messageText.Split(new char[] { ' ', ',' },
StringSplitOptions.RemoveEmptyEntries);
foreach (WordFilter Filter in this._filteredWords.ToList())
{
count += wordsInMessage.Count(x => x == Filter.Word);
}
return count >= 3;
}
If I remove special characters such as !from words, it will work. I could just add these characters to the char list, but certainly there is a very simple method?
source
share