COutn the number of words

J

janet

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
 
K

Ken Schaefer

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

: 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
 
E

Evertjan.

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top