Extract keywords from text and exclude words
arrays, c#, regex, string
Solution
string strWordsToExclude="if,you,me,about,more,but,by,can,could,did";
var ignoredWords = strWordsToExclude.Split(',');
return words.Except(ignoredWords).ToArray();
I think `Except` method fits your needs
Problem
I have this function to extract all words from text ``` public static string[] GetSearchWords(string text) { string pattern = @"\S+"; Regex re = new Regex(pattern); MatchCollection matches = re.Matches(text); string[] words = new string[matches.Count]; for (int i=0; i<matches.Count; i++) { words[i] = matches[i].Value; } return words; } ``` and I want to exclude a list of words from the return array, the words list looks like this ``` string strWordsToExclude="if,you,me,about,more,but,by,can,could,did"; ``` How can I modify the above function to avoid returning words which are in my list.