Regex is driving me nuts tonight.
what I am trying to do ( as illogical as this goal may sound ) is to eliminate open/close tag pairs and their content. For example, in the following, I want to eliminate the part in red:
<b class='test another' id='x'>hey<i><span class='sp'> some more stuff </span><em>
in this example i want to target the open span.. its class... its content and then its closing span tags so that I get this :
<b class='test another' id='x'>hey<i><em>
( sorry, am being redundant)
I figured this was a job for preg_replace and a GOOD regex expression, this is what I have thus far...
thinking that the regexp expression I created means the following...
( look for a pattern
^< that begins with "<" and is followed immediately by
(.+) a pattern containing one or more charters ( captured pattern #2)
\s? maybe followed by a space or no space
.* maybe followed by 0 or more charcters
>)and lastly an ">"
.* after that there be 0 or more characters
( then another pattern
</ which starts with "</" and is followed by
(?(2)(.+))a pattern containing one or more charters which MATCH the characters of captured pattern #2 and is followed by
>) / and lastly an ">" , end search...
somewhere I am off... I would appreciate any fresh perspective on this...
thanks in advance