Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > COutn the number of words

Reply
Thread Tools

COutn the number of words

 
 
janet
Guest
Posts: n/a
 
      09-08-2003
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
 
Reply With Quote
 
 
 
 
Ken Schaefer
Guest
Posts: n/a
 
      09-08-2003
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" <(E-Mail Removed)> wrote in message
news:422001c375da$709a0c10$(E-Mail Removed)...
: 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


 
Reply With Quote
 
 
 
 
Evertjan.
Guest
Posts: n/a
 
      09-08-2003
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)
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: Words and non-words, according to Microsoft et al Steve B NZ Computing 11 03-21-2008 11:52 PM
Replace stop words (remove words from a string) BerlinBrown Python 6 01-17-2008 02:37 PM
Words Words utab C++ 6 02-16-2006 07:00 PM
Non-noise words are incorrectly recognised as noise words. Peter Strĝiman ASP .Net 1 08-23-2005 01:26 PM
Re: A little bit of help regarding my linked list program required. - "words.c" - "words.c" Richard Heathfield C Programming 7 10-05-2003 02:38 PM



Advertisments