How to Modify Function to Trim a String by Paragraphs Instead of Number of Characters?
Posted on 2004-04-28
I have a function to replace the first x number of characters in a string and not cut them in the middle of words. Works great. Question, how can iit be modified to only return, for example, the first two paragraphs (after the </p>)? Running W2K, ASP 3.0. Here's the code:
In an include file:
FUNCTION TrimString(strString, intLength)
strString = Replace(strString, vbCrLf, "")
If Len(strString) > intLength Then
strString = Left(strString, intLength)
aryString = Split(strString, " ")
strString = ""
For a = 0 to UBound(aryString)-1
strString = strString & " " & aryString(a)
strString = Trim(strString)
strString = strString & " ..."
TrimString = strString
to call it on the page
intLength = 300
strString = TrimString(strString, intLength)
Thanks in advance!