Jump to content

Find & Replace Opening and Closing tags..


squiggerz

Recommended Posts

I sort of asked this in the regex section but this may require a more general answer, I'm not sure. Here's what I got:

 

 <a name="blah blah blah"> <b> Blah blah blah </b> </a> 

 

I added the spaces in between the tags for readability, they are either there or not in the code I'm trying to mutate.

 

What I'm trying to do is get rid of the opening and closing 'a' tags, is there an easy way to do this and make sure that only THAT set of 'a' tags get removed and leave the rest alone?

 

Thanks,

          Sq

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/79377-find-replace-opening-and-closing-tags/
Share on other sites

Ok, let's say I preg_replace the a name="blah blah blah"> tag with nothing. Now I'm left with a whole bunch of '/a>' tags, can I use some sort of preg replace or something that checks only for ending 'a' tags that are NOT preceeded by opening a tags before hitting a preceeding '/a' tag? Maybe something like:

((??<!(?:<a (.*?)>)).)*)

 

Yeah I know, I'm terrible with regex.. lol

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.