something like that
private static int occurencesOf(String Value_, String ToSearchIn_) {
return new Regex("(" + Value_ + ")+", RegexOptions.CultureInvariant | RegexOptions.Compiled).Matches(ToSearchIn_).Count;
}
oops... forget usage...
string testText = "This is my name";
Console.WriteLine(occurencesOf("is", testText));
and
using System.Text.RegularExpressions
[edit]and I should avoid question when I'm in a hurry.... it's Match
es(ToSearchIn_).Count[/edit]