Javascript/C# Word Count
A function to count the number of words in Javascript:
function CountWords(w){
var fc = w.split(" ");
return fc.length;
}
Simple as it is, I’ve been asked for it a million times…
In C#, it’s equally simple:
public int CountWords(string ToCount)
{
return ToCount.Split(' ').Length;
}
By Mikhail Esteves | July 25th, 2005 in
Tips


TMTOWTDI
function CountWords(w)
{
var a = w.match(/\w+/g);
return a.length;
}