Welcome to Dream.In.Code
Getting Help is Easy!

Join 109,157 Programmers for FREE! Ask your question and get quick answers from experts. There are 1,030 online right now! We've got more than 500 tutorials and 2,000 snippets. Join and find out why Dream.In.Code is the #1 programming help community on the internet! 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
post 18 Mar, 2008 - 01:22 PM
Post #1


New D.I.C Head

*
Joined: 23 Jan, 2008
Posts: 5

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

Go to the top of the page

Fast ReplyReply to this topicStart new topic
Time is now: 9/5/08 05:39PM

Live Help!

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month