Jump to content

Help removing this string


chronister

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/219856-help-removing-this-string/
Share on other sites

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!

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.