Regex for javascript to count words (excluding numbers) -
i have function
string.prototype.countwords = function(){ return this.split(/\s+\b/).length; }
which counts words in textarea, counts numbers inserted, wondering how count words not numbers, ignoring numbers,
the following regex might out:
string.prototype.countwords = function(){ return this.split(/\s+[^0-9]/).length; }
the ^
negates characters in brackets, characters allowed follow whitespaces except numbers.
by way: here place test regex: http://regexpal.com/
Comments
Post a Comment