I need to keep only some properties of the style attribute in tags present in a string of an html document, they will be placed in a whitelist, everything else will be removed. In the example below:
<TD class=xl76 style="BORDER-TOP: windowtext 0.5pt solid; HEIGHT: 15pt; BORDER-RIGHT: windowtext 0.5pt solid; WIDTH: 883pt; BORDER-BOTTOM: windowtext 0.5pt solid; BORDER-LEFT: windowtext 0.5pt solid; BACKGROUND-COLOR: transparent" height=20 width=1177 colSpan=25><FONT face=Calibri><STRONG>INDICADORES DO MÊS DE ABRIL DE 2016</STRONG></FONT></TD>
I would just keep the border and the background and delete the rest of the style from the column:
<TD style="BORDER-TOP: windowtext 0.5pt solid; BORDER-RIGHT: windowtext 0.5pt solid; BORDER-BOTTOM: windowtext 0.5pt solid; BORDER-LEFT: windowtext 0.5pt solid; BACKGROUND-COLOR: red"><FONT face=Calibri><STRONG>INDICADORES DO MÊS DE ABRIL DE 2016</STRONG></FONT></TD>
I can isolate the contents of style with the following regex:
/(style=")([\s\S])(")/gi
But how to remove, keep the css?