从html标签中删除所有内联css只有异常不是删除display:none propety

want to remove all css rules from inline css but not to remove display none property

for example,

 <p style="color:red;display:none;float:left;">

I Tried this I am using php simple HTML DOM parser

and snippet is here

 foreach ($obj->find('img') as $e) {
        $imgSrc = $e -> src;
        preg_match_all('~' . SITE_NAME . '~is', $imgSrc, $match);
        if (count($match[0]) == 0) {
            $loadedSrcs = SITE_NAME . $imgSrc;
        } else {
            $loadedSrcs = $imgSrc;
        }

        $currentImageSrc = $e -> outertext;
        $replacementImageSrc = "src='" . $loadedSrcs . "'";
        $changeSrc = preg_replace('/src=[\'|\"][^\'|\"]*[\'|\"]/is', $replacementImageSrc, $currentImageSrc);
        //$imageSrc = "<img src=".$changeSrc." />";

       $ImagesWithFullPath = preg_replace('~<img [^c]*c=[\'|\"]'.$e -> src.'[^\>]*\>~is', $changeSrc , $ImagesWithFullPath);

    // now I want to remove diffrent style property from Image and wandering how could I write the preg_replace not display:none 

}

Hope it helps to understand my Query

I want to do it with preg_replace(php) not with Jquery.

Any help will be highly appreciated.

Once you get the proper element with an HTML parser:

$styles = array_map('trim', explode(';', $e->style));
if (in_array('display:none', $styles)) {
    $e->style='display:none';
}
else {
    $e->style='';
}