SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Addict cranjled's Avatar
    Join Date
    Apr 2004
    Location
    ny
    Posts
    382
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Muliline preg_replace help needed

    Hi,

    I have a string of HTML from which I'd like to remove a table and image link. The image and link are arbitrary, as are the attributes of the table itself. Additionally, there may or may not exist such tags as *th, *thead or *tbody within the table. I believe that preg_replace() is the proper solution, but as there are too many circumstances to allow for, I'm doing more reading than anything...and getting more confused as I go...

    Can someone reveal the pattern for removing the following (frameworked) HTML? The pattern will always be removing a table (and a following *br), so the basic table tags will be present, however, the tags will have arbitrary attributes, and the *th, *thead and *tbody tags may be arbitrarily present as well. Finally, the markup will be found on more than a single line.

    Code:
    <table><tr><td><a><img /></a></td></tr></table><br />
    Thanks for your time,

    Cranjled

  2. #2
    ✯✯✯ silver trophybronze trophy php_daemon's Avatar
    Join Date
    Mar 2006
    Posts
    5,284
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    try
    Code:
    #<table>.*?<a .*?><img .*?/></a>.*?</table><br />#is
    Saul


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •