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
The correct regexp would be /s+/ in order to discard non-words:
/s+/
'Lorem ipsum dolor , sit amet'.split(/\S+/g).length 7 'Lorem ipsum dolor , sit amet'.split(/\s+/g).length 6