473,395 Members | 1,554 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,395 software developers and data experts.

showing only x number of characters

I am using a WYSIWYG editor for articles and the article text is being
inserted into a SQL db field called ARTICLEBODY.

Question:
On my homepage, I only want to display the first 400 characters of
ARTICLEBODY field. I am using the LEN function and it does what I want.
BUT, is there a way to not have it cutoff in the middle of a word?

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 19 '05 #1
3 1162
In your SQL query or using vbscript or jscript in your ASP page? If in your
query, what kind of database? If in your code, what relevant code snippet
are you currently using?

Ray at work
"Joey Martin" <jo**@infosmiths.net> wrote in message
news:ui**************@TK2MSFTNGP15.phx.gbl...
I am using a WYSIWYG editor for articles and the article text is being
inserted into a SQL db field called ARTICLEBODY.

Question:
On my homepage, I only want to display the first 400 characters of
ARTICLEBODY field. I am using the LEN function and it does what I want.
BUT, is there a way to not have it cutoff in the middle of a word?

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Jul 19 '05 #2
Joey Martin wrote on 09 sep 2004 in
microsoft.public.inetserver.asp.general:
I am using a WYSIWYG editor for articles and the article text is being
inserted into a SQL db field called ARTICLEBODY.

Question:
On my homepage, I only want to display the first 400 characters of
ARTICLEBODY field. I am using the LEN function and it does what I want.
BUT, is there a way to not have it cutoff in the middle of a word?


Sure, many ways.

the nicest ones are in ASP jscript:

t = t.replace(/^(.{0,400}) .*$/,'$1')

or if you do not like regex:

t = t.substr(0,401).split(' ').slice(0,-1).join(' ')

tested, but not tested for exact 400 max

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress,
but let us keep the discussions in the newsgroup)

Jul 19 '05 #3
http://www.aspfaq.com/2398

--
http://www.aspfaq.com/
(Reverse address to reply.)


"Joey Martin" <jo**@infosmiths.net> wrote in message
news:ui**************@TK2MSFTNGP15.phx.gbl...
I am using a WYSIWYG editor for articles and the article text is being
inserted into a SQL db field called ARTICLEBODY.

Question:
On my homepage, I only want to display the first 400 characters of
ARTICLEBODY field. I am using the LEN function and it does what I want.
BUT, is there a way to not have it cutoff in the middle of a word?

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Jul 19 '05 #4

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

Similar topics

10
by: .:mmac:. | last post by:
My ASP page is doing something wierd, I think it has something to do with the %2E replacing the dot in the file name But in addition, if I right click the link and select "save as", the file...
14
by: beginner10 | last post by:
How can i changhe this code showing how many persons i saved to the file? And it prints pretty much rubbish. Where is the problem? #include <stdio.h> int main() { int i; FILE *data_file;...
122
by: Einar | last post by:
Hi, I wonder if there is a nice bit twiddling hack to compare a large number of variables? If you first store them in an array, you can do: for (i = 0; i < n; i++) { if (array != value) {...
4
by: Tim Anderson | last post by:
I have VS 2003 installed on one machine, and the newly downloaded VS 2005 release on another. Both XP Pro. I have code like this: string s = "Extended characters: <spade> spades";...
2
by: jaekim | last post by:
Visual .NET c# design view is showing "?????" for all the Korean characters in design view. In code view, it looks okay. Did anybody have this kind of problem with foreign characters?
15
by: pinkfog | last post by:
hi,all I write a snippet(in VC6.0 PLATFORM) to show the ASCII character ranging from 0-255. snippet: #include "stdafx.h" #include "stdio.h" #include "conio.h" int main(int argc, char* argv) {...
1
by: mfurey | last post by:
Can someone look at the following page and tell me what I did wrong with the style sheet linkage, or perhaps the document type declaration? I had this working properly off of one server, but now...
2
by: Timbo | last post by:
Hi there, I’m not used to working in VB and I think this situation calls for excactly that. I use Access 97 SR-2. My first table is a table containing all the Tickets I got. The field ”Ticket”...
1
by: dantz | last post by:
Hi everyone, I have a textbox which is multiline and wordwrap is true. I did not set any scrollbar because I want to show it manually (using different buttons) The textbox will sometimes have...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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.