473,804 Members | 3,330 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

COutn the number of words

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
Jul 19 '05 #1
2 2079
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" <kn*******@hotm ail.com> wrote in message
news:42******** *************** *****@phx.gbl.. .
: 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
Jul 19 '05 #2
janet wrote on 08 sep 2003 in microsoft.publi c.inetserver.as p.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)
Jul 19 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

21
2166
by: Alex Martelli | last post by:
I hesitate a bit to post this, but... on the Italian Python NG, somebody was asking whether there was any way to convert an integer number x into a string which represents it in an arbitrary base N (given a sequence with a len of N that gives the digits to use) as "a single expression". I haven't found a really general way, much less a clear one, but, the best I have so far is...: def number_in_base(x, N, digits, maxlen=99): return...
2
4359
by: Sebek | last post by:
Hello, I'm transforming a XML document in XHTML but I have problems using sub-strings, it will be clearer with an exemple: What I have: <form href="identification.php?PHPSESSID=134134&page=2&param=3" > </form> what I want:
9
52916
by: cw bebop | last post by:
Hi all Using Visual Studio C# Have a string string st = "Hi, these pretzels are making me thirsty; drink this tea. Run like heck." ******
5
2625
by: VJ | last post by:
Is there any known component that would convert a value entered as 40,000 to Forty Thousand.. Thanks VJ
4
1529
by: JaredEmery | last post by:
Hello all, It's my first database, and I have a query that shows me the quantity, material, length, width and thicknesses of parts, and I'm using these figures to do some arithmetic on a report to show me how many board feet of lumber to buy (expression is as follows): =( * * /144) * (Val()/4) If you're wondering what the Val statement is for, it's to grab the
6
3270
by: Gary Wessle | last post by:
hi I have a data file with equal number of columns for each row. I need to get the number of rows and columns to allocate a matrix in gsl. getline (in, line) and parse the line for the number of spaces then add one to get the number of words then number_of_rows = 1; while getline (in, line) and number_of_rows++ does the number of rows I am not sure how to go about the number of words task, is there a c++
3
6357
by: Nhd | last post by:
I have a question which involves reading from cin and counting the number of words read until the end of file(eof). The question is as follows: Words are delimited by white spaces (blanks, tabs, linefeeds, returns). It will print 3 pieces of information before exit: the first word, the last word, and the number of words read, with one blank in between fields. Input lines of words Output
0
2385
by: Tigerlily | last post by:
Hello! I need to count the number of words in a string read in from an infile, in a function, but I don't know how to do this. This is what I have so far. //Tiffany Lynn Goodseit #include <iostream> #include <fstream> #include <string> using namespace std; void diffwords(string &line); int main()
2
3418
by: alwaali | last post by:
Hi I need help please This is my project and i need a help to solve it with you A page of text is to be read and analyzed to determine number of occurrences and locations of different words. The results of the analysis are to be stored in a suitable data structure. The main task in this project is to design a suitable ADT (call it WAnalysis) to store the results and enable the following operations to be performed as fast as possible:...
0
9579
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10075
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9143
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7615
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6851
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5520
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5651
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3815
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2990
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.