Using the answers here i made this extension method that finds multiple words in a text, returns the amount of words found, and ignores case matching.
public static int Search(this String text, params string[] pValores)
{
int _ret = 0;
try
{
var Palabras = text.Split(new char[] { ' ', '.', '?', ',', '!', '-', '(', ')', '"', '\'' },
StringSplitOptions.RemoveEmptyEntries);
foreach (string word in Palabras)
{
foreach (string palabra in pValores)
{
if (Regex.IsMatch(word, string.Format(@"\b{0}\b", palabra), RegexOptions.IgnoreCase))
{
_ret++;
}
}
}
}
catch { }
return _ret;
}
Usage:
string Text = @"'Oh, you can't help that,' (said the Cat) 'we're all mad here. I'm MAD. ""You"" are mad.'";
int matches = Text.Search("cat", "mad"); //<- Returns 4
It's not perfect but it works.