Two solutions to that:

If you hit the end of the truncated string and you're inside a tag, just back out the 
whole tag.

Alternatively, don't simply truncate the string.  Scan through to a point that is not 
inside a tag, then check to see if you're past your limit, and chop it if you are.

You really need to determine what to do with tags anyway - they shouldn't simply count 
as the equivalent number of characters, as they could take up no space at all, or be 
huge, depending on what they are.

Worse still, leaving tags in could conceivably break your HTML - you'd be better 
stripping all tags out.

Dave S
  ----- Original Message ----- 
  From: Moshe Tapnack 
  To: [EMAIL PROTECTED] 
  Cc: [EMAIL PROTECTED] 
  Sent: Thursday, September 23, 2004 8:08 PM
  Subject: RE: [ASP] Counting "s


  Hi Dan and Soren

  Soren - the below Url is a good example of what I mean.

  Dan, yes, search for the closing ">" might do the trick (count < and then
  see if there are the same >'s) , but then again, if I have

  <img src="ima

  Even tho I close the tag with the > I don't think the link afterwards will
  show, like this: 

  <P><IMG src="http://www.ze...    >
       <p><a href="viewItem.asp?idProduct=778">More...</a>

  Any recommendatiosn for this case? I don't really want to strip HTML tags,
  cos if the img tag is complete - I do want the image to show.
  But if you send me that script anyway, I would appreciate it

  Thanks again!
  Moshe


  ---
  Outgoing mail is certified Virus Free.
  Checked by AVG anti-virus system (http://www.grisoft.com).
  Version: 6.0.760 / Virus Database: 509 - Release Date: 10/09/2004

[Non-text portions of this message have been removed]



------------------------ Yahoo! Groups Sponsor --------------------~--> 
Make a clean sweep of pop-up ads. Yahoo! Companion Toolbar.
Now with Pop-Up Blocker. Get it for free!
http://us.click.yahoo.com/L5YrjA/eSIIAA/yQLSAA/17folB/TM
--------------------------------------------------------------------~-> 

---------------------------------------------------------------------    
 Home       : http://groups.yahoo.com/group/active-server-pages
---------------------------------------------------------------------
 Post       : [EMAIL PROTECTED]
 Subscribe  : [EMAIL PROTECTED]
 Unsubscribe: [EMAIL PROTECTED]
--------------------------------------------------------------------- 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/active-server-pages/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 



Reply via email to