Hi,

You could you the split function (assuming words are space sperated)

var mySplitResult = oXmlHttp.responseText.split(" ");

mySplitResult.length            - Gives the array length, hence the number
of words - 1 (if I remember correctly)



On Mon, Jul 27, 2009 at 11:46 PM, Ricardo <ricardob...@gmail.com> wrote:

>
> As "ButtersRugby" said, usually you'll count characters because of a
> 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

Reply via email to