string length limit for some field or display, so you'll want to take
all punctuation and spaces into account. Counting letters only is
rarely a real requirement.
s.match(/\w/g).length makes more sense at first sight, despite being
probably slower.
-- ricardo
On Jul 27, 8:23 pm, RobG <robg...@gmail.com> wrote:
> 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:
Post a Comment