Reputation: 147
I have this html code.
<P class=MsoNormal style='MARGIN: 0cm 0cm 10pt'><STRONG>text</P>
<P class=MsoNormal style='MARGIN: 0cm 0cm 10pt'></P>
<UL>
<LI>
<DIV class=MsoNormal style='MARGIN: 0cm 0cm 10pt'>text</DIV></LI>
<LI>
<DIV class=MsoNormal style='MARGIN: 0cm 0cm 10pt'>text</DIV></LI>
<LI>
<DIV class=MsoNormal style='MARGIN: 0cm 0cm 10pt'>text</DIV></LI>
<LI>
<DIV class=MsoNormal style='MARGIN: 0cm 0cm 10pt'>text</DIV></LI>
<LI>
<DIV class=MsoNormal style='MARGIN: 0cm 0cm 10pt'>text</DIV></LI>
<LI>
<DIV class=MsoNormal style='MARGIN: 0cm 0cm 10pt'>text</DIV></LI></UL>
I want remove style tag and its proprieties as well as class tag and its proprieties so the out would be :
<P><STRONG>text</P>
<P></P>
<UL>
<LI>
<DIV>text</DIV></LI>
<LI>
<DIV>text</DIV></LI>
<LI>
<DIV>text</DIV></LI>
<LI>
<DIV>text</DIV></LI>
<LI>
<DIV>text</DIV></LI>
<LI>
<DIV>text</DIV></LI></UL>
Here is what i have tried but it is not working :
$html = preg_replace('/(]+) (style|class)=("|\').*?("|\'(>|\s))/img', '$1', $$html);
Upvotes: 1
Views: 1344
Reputation: 848
try this:
$html = preg_replace("/(\s(class|style)[^>]+)/", "", $html);
Upvotes: 1