COutn the number of words

Discussion in 'ASP General' started by janet, Sep 8, 2003.

  1. janet

    janet Guest

    how can i count how many words have i written in a text
    area???

    Like taking an example ... i am writing in this textarea
    of microsoft usergroup. and say in total i have written 50
    words .. how can find out this information?

    thanks
     
    janet, Sep 8, 2003
    #1
    1. Advertising

  2. janet

    Ken Schaefer Guest

    You need to define what a word is. If all words are merely characters
    separated by spaces, then you can just count the number of spaces in your
    text-area, and add 1.

    For example the following text:

    The quick brown fox jumped over the lazy dog.

    has 8 spaces. Add 1, and you get 9, which is the number of words. However,
    judging by the quality of spelling et al in your post, this may not be an
    entirely accurate measure of the number of words that you'd have typed into
    a textarea.

    Cheers
    Ken

    "janet" <> wrote in message
    news:422001c375da$709a0c10$...
    : how can i count how many words have i written in a text
    : area???
    :
    : Like taking an example ... i am writing in this textarea
    : of microsoft usergroup. and say in total i have written 50
    : words .. how can find out this information?
    :
    : thanks
     
    Ken Schaefer, Sep 8, 2003
    #2
    1. Advertising

  3. janet

    Evertjan. Guest

    janet wrote on 08 sep 2003 in microsoft.public.inetserver.asp.general:
    > how can i count how many words have i written in a text
    > area???
    >
    > Like taking an example ... i am writing in this textarea
    > of microsoft usergroup. and say in total i have written 50
    > words .. how can find out this information?


    When you have submitted the string to serverside ASP
    [If you want a clientside solution please go elsewhere]

    first trim and change all multiple whitespace to single spaces,
    then count your spaces and add one:

    Serverside Jscript:

    s = " blah blah blah "
    s = s.replace(/(^\s+)|(\s+$)/g,"")
    s = s.replace(/\s+/g," ")
    s = s.split(" ")
    l = s.length - 1 + 1

    ===================

    more concise:

    s = " blah blah blah "
    l = s.replace(/(^\s+)|(\s+$)/g,"").replace(/\s+/g," ")
    .split(" ").length
    // make one line of the two above



    --
    Evertjan.
    The Netherlands.
    (Please change the x'es to dots in my emailaddress)
     
    Evertjan., Sep 8, 2003
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Peter Strøiman
    Replies:
    1
    Views:
    2,110
    Peter Strøiman
    Aug 23, 2005
  2. Richard Heathfield
    Replies:
    7
    Views:
    380
    Barry Schwarz
    Oct 5, 2003
  3. utab

    Words Words

    utab, Feb 16, 2006, in forum: C++
    Replies:
    6
    Views:
    436
    Daniel T.
    Feb 16, 2006
  4. BerlinBrown
    Replies:
    6
    Views:
    4,640
  5. Lasse Edsvik

    replace words with bold words

    Lasse Edsvik, Oct 5, 2003, in forum: ASP General
    Replies:
    9
    Views:
    243
Loading...

Share This Page