Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Displaying First Paragraph of a String

Status
Not open for further replies.

sevex

Programmer
Joined
Sep 18, 2001
Messages
74
Location
CA
I want to display only the first paragraph of a string (body). Below is the code I'm currently using, which works for the most part, but in a string containing a "P" character, it will cut off there, instead of at the end of the paragraph.

#SpanExcluding(ParagraphFormat(body), &quot;<P>&quot;)#

Anyone have any suggestions? A better way to do this maybe?

Thanks
 
SpanExcluding asks the search to stop at the first occurrence of ANY of the characters in the set. You haven't noticed, but your scan would stop at &quot;<&quot; or &quot;>&quot; as well as &quot;P&quot;. The function combo you want is:

Code:
Left( ParagraphFormat(body), FindNoCase( ParagraphFormat(body), &quot;<P>&quot; ))

Well, since you're using ParagraphFormat(body), Find() will work as well as FindNoCace().

Find returns the index of the substring, as opposed to the index of any one character in the substring, so it should do the trick.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top