private static readonly Regex NonSymbols = new Regex("([a-zA-Z0-9]+)", RegexOptions.Compiled); // Words without symbols. //private static readonly Regex NonSymbols = new Regex("(\S+)", RegexOptions.Compiled); // Any words. static IEnumerable GetUniqueWords(string input) { return AllWord(input).Distinct(); } static IEnumerable AllWord(string input) { return NonSymbols.Matches(input.ToLower()).OfType().Select(s => s.Value); } static long LargestSingleWordCount(string input) { IEnumerable words = AllWord(input); return words.Distinct().Max(s => words.Count(t => t == s)); }