I am trying to do this regex match and replace but not able to do it.
Example
<SPAN class="one">first content here</SPAN>
<SPAN class="two">second content here </SPAN>
<SPAN class="three">one; two; three; and more.</span>
<SPAN class="four">more content here.</span>
I want to find each set of the span tags and replace with something like this
Find
<SPAN class="one">first content here</SPAN>
Change to
<one>first content here</one>
same way the the rest of the span tags.
class="one"
, class="two"
and so on are the only key identifier which I use in the regex match expression. So if I find a span tag with these class then I want to do the replace. My main issue is that I am not able to find the occurrence of first closing tag so what it does is it finds from the start to end which is of no use. So far I have been trying to do this using notepad++ but just found that it has its limitations so any php help would be appreciated.
regards
preg_replace('/<span class="(.*?)">(.*?)<\/span>/i', '<$1>$2</$1>', $input);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With