chronister Posted November 25, 2010 Share Posted November 25, 2010 Hello all... Happy Turkey Day for those who celebrate Thanksgiving, and Happy Thursday for everyone else I am code scraping a page and I have managed to hack together a couple regex patterns that remove pieces I want gone in the code, but I am having trouble on this one. I have looked and just cannot wrap my brain around this regex stuff. I have a string of text (html source code) and want to find and remove all occurrences of this string. <sup class='footnote' value='[<a href="XXX" title="See footnote XXX">XXX</a>]'>[<a href="XXX" title="See footnote XXX">XXX</a>]</sup> In all the places you see XXX this is variable information. I have tried some expressions, but they did not work. I am not sure if it is possible to simply find and replace everything between and including <sup class='footnote' XXXXXXXX </sup> Thanks in advance for help, Nate Quote Link to comment Share on other sites More sharing options...
MrXHellboy Posted November 26, 2010 Share Posted November 26, 2010 I am absolutely not sure what you want, but this removes the whole thing. <?php error_reporting(E_ALL); $a = "<sup class='footnote' value='[<a href=\"XXX\" title=\"See footnote XXX\">XXX</a>]'>[<a href=\"XXX\" title=\"See footnote XXX\">XXX</a>]</sup>"; echo preg_replace('@<sup (.*)>(.*)<\/sup>@', '', $a); ?> If this is not what you want, please correct me and show me a example of how it must be! Quote Link to comment Share on other sites More sharing options...
sasa Posted November 30, 2010 Share Posted November 30, 2010 $patern = '#<sup class=\'footnote\' value=\'\[<a href="[^"]*" title="See footnote [^"]*">[^<]*</a>\]\'>\[<a href="[^"]*" title="See footnote [^"]*">[^<]*</a>\]</sup>#'; Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.