Welcome to Dream.In.Code
Become an Expert!

Join 136,929 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 1,830 people online right now. Registration is fast and FREE... Join Now!




how can i trim at the last occurance of a character?

 
Reply to this topicStart new topic

how can i trim at the last occurance of a character?

sjlsam
18 Mar, 2008 - 12:22 PM
Post #1

New D.I.C Head
*

Joined: 23 Jan, 2008
Posts: 7

Let's say I've got a set of strings being drawn from a database that look like this:
"<p><strong>This is a test<stro" (NEEDS TRIMMING)
"<p>This is a test 2</p><br />Hi." (GOOD)
"<i>This is a test 3</i" (NEEDS TRIMMING)

I want to trim my results so that the two strings with incomplete HTML become:
"<p><strong>This is a test" (TRIMMED)
"<i>This is a test 3" (TRIMMED)

So basically I want to trim off from "<" to the end of my string, but only in the situation that a finalizing ">" is not present.

Normally I would think to make my strings into a list delimited by "<" and then removing the last item, but that would also trim all the GOOD statements that have terminating ">"'s.

Can someone lead me in the right direction? I've been scratching my head over this for a couple of days.

Thanks,
Sam
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 12/3/08 10:30PM

Live Help!

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month