I\'m trying to put together a regular expression for a JavaScript command that accurately counts the number of words in a textarea.
One solution I had found is as fo
For me this gave the best results:
value.split(/\b\W+\b/).length
with
var words = value.split(/\b\W+\b/)
you get all words.
Explanation:
I recommend learning regular expressions. It's a great skill to have because they are so powerful. ;-)