Regex for javascript for word count (excluding numbers)
2 answers
The following regex might help you:
String.prototype.countWords = function(){
return this.split(/\s+[^0-9]/).length;
}
^
cancels the characters in parentheses, so all characters are allowed to follow spaces except for any numbers.
By the way: here's a good place to test your regex: http://regexpal.com/
+1
source to share