Monday, July 27, 2009

[jQuery] Re: How to deterine number of words in a string?

On Jul 28, 5:09 am, Liam Byrne <l...@onsight.ie> wrote:
> A letter count is FAR easier - just get the string's length.

The length of the string will give you a *character* count. I would
not inlcude punctuation, white space, etc. in a *letter* count. For
number of letters, try:

s.replace(/[^a-zA-Z]/g,'').length;


--
Rob

No comments: