I would like to check how many words in a string
eg.
asdsd sdsds sdds
3 words
The problem is , if there is more than one space between two substring , the result is not correct
here is my program
function trim(s) {
return s.replace(/^\s*|\s*$/g,"")
}
var str = trim(x[0].value);
var parts = str .split(" ");
alert (parts.length);
How to fix the problem? thanks for help