Jump to content


Photo

Searching for 2 strings and removing them and data between them


  • Please log in to reply
1 reply to this topic

#1 dagnasty

dagnasty
  • Members
  • PipPipPip
  • Advanced Member
  • 66 posts

Posted 04 July 2006 - 07:34 AM

I'm having a lot of trouble with this. My brain just fails when I start looking at expressions that do similar to these, regardless of the complexity. I'd very much appreciate some enlightenment.

I want to remove this sement of html (in this case a <TD>) that occurs multipletimes in a string...

<td class="vertTh"><a href="brwsearch.php?b=1&amp;c=201" title="More from this category">Video > Movies</a></td>

... the contents of the TD contain something new every in every instance but it contains the same opener and closer. (<td class="vertTh"> and </td>)

I suppose I'll be looking for both

<td class="vertTh"> and </td>

but I don't understand how to tell it to remove it completely.

Sorry about my poor explanation. It's 4 am and I'm going nuts.

Thanks to anyone willing to enlighten me! :)



#2 Wildbug

Wildbug
  • Members
  • PipPipPip
  • Advanced Member
  • 1,149 posts

Posted 04 July 2006 - 02:33 PM

preg_replace('/<td class="vertTh">(.*?)<\/td>/si',"$1",$yourTextVariable);

That should work.
Twice a day my clock works PERFECTLY!  I can't figure out what's wrong with it.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users