How to count number of word in text
-
Hi I need a code example or an known Object that can count the number of word in a text eyalso
Why don't you try using string.Split(" \t\n.;:\"\'") with cleaning empty results? may be some more symbols, but you got the idea. You can use Regex for same effect... ____________________________________________ Robin Panther http://www.robinland.com
-
Why don't you try using string.Split(" \t\n.;:\"\'") with cleaning empty results? may be some more symbols, but you got the idea. You can use Regex for same effect... ____________________________________________ Robin Panther http://www.robinland.com
-
string input="Hello World!"+Environment.NewLine+"Goodbye World.";
int wordCount=Regex.Matches(input,"[\\w\'-]+").Count;
Console.WriteLine("Word Count: {0}",wordCount);
Needs further testing, and probably not perfect. But on the tests I have done so far, it seems to account for itself. Hope this helps, Graham. -- modified at 17:50 Sunday 30th April, 2006