4 Replies Latest reply on Mar 19, 2008 2:03 PM by JohnEric

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

      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.