473,396 Members | 1,938 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Classic ASP text input word count problem???

I am trying to build an asp page the displays 100 characters from text
inputed into a text area. The page keeps breaking because it counts any HTML
code the text might have. I would like to have it count the words instead and
when I write out the words it includes any underlying html.

For example, here is a sentence: "The fox jumps over the lazy dog" and I
could cut this sentence in half by counting out the first 18 character and
only outputing those respectively. Everything would work just fine. But if
the sentence is like this "The fox jumps <a href='http://www.microsoft.com'
target='_blank'>over</a> the lazy dog." a simple letter count no longer works
for me. If I printed out the first 18 characters then it will break my "href"
tag and therefore would mess up the formatting of my page. Can someone point
me to an article or component that will assist me in correcting this? Thanks!

Eddie
Feb 15 '06 #1
1 2658
=?Utf-8?B?YWR1ZGUyOA==?= wrote on 15 feb 2006 in
microsoft.public.inetserver.asp.general:
For example, here is a sentence: "The fox jumps over the lazy dog" and
I could cut this sentence in half by counting out the first 18
character and only outputing those respectively. Everything would work
just fine. But if the sentence is like this "The fox jumps <a
href='http://www.microsoft.com' target='_blank'>over</a> the lazy
dog." a simple letter count no longer works for me. If I printed out
the first 18 characters then it will break my "href" tag and therefore
would mess up the formatting of my page. Can someone point me to an
article or component that will assist me in correcting this? Thanks!


<script runat=server language=jscript>

s = "The fox jumps <a href='http://www.microsoft.com' "+
"target='_blank'>over</a> the lazy dog.";

wordCount = s.replace(/<[^>]*>/g,'').split(' ').length; // 7

response.write('The number of words is ' + wordCount);

</script>

nothing is perfect though, this will fail:

.... <a href='..' alt='Less than is written ">"'> ...
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Feb 15 '06 #2

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

Similar topics

9
by: dan | last post by:
this is a program to count average letters per word. i am able to count the total number of letters, but not words. How do you count the total number of words in a text file, so i am able to divide...
8
by: FUGATO | last post by:
I need to help in my assignment. I need to wrap a text with the following indications: 1.If you have reached the end of the line (number of characters on this line >= 40) AND you have reached the...
2
by: Peter2 | last post by:
Hi, I have a problem posting non-ASCII characters in FORM fields between classic ASP and ASP.NET. I use a fully patched Windows 2000 Advanced Server with .net 2.0 and visual Studio 2005 installed,...
4
by: bigbagy | last post by:
Notes The programs will be compiled and tested on the machine which runs the Linux operating system. V3.4 of the GNU C/C++ compiler (gcc ,g++) must be used. A significant amount coding is...
3
by: acecraig100 | last post by:
I am fairly new to Javascript. I have a form that users fill out to enter an animal to exhibit at a fair. Because we have no way of knowing, how many animals a user may enter, I created a table...
1
by: samoukos | last post by:
Hello everyone, around one weeek ago i started to learn the c++ language. And i try to solve different programs i found from a text book i got here in greece. But i got to a chapter and i have met...
9
by: plumba | last post by:
Hi all I have a pretty cool script which, on the click of a button, sticks in a extra text box and gives it a unique name/id so it can be munipulated and sent through on a form. Problem is, I...
21
by: arnuld | last post by:
I have created a program to print the input words on stdout. Input is taken dynamically from stdin. In each word, each input character is allocated dynamically. I have ran this program with a file...
5
by: Matt | last post by:
I originally posted this in microsoft.public.sqlserver.server, and it was suggested that I post here. I'm having problems with searches via a classic ASP front-end of terms including foreign...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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...
0
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,...

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.