20,359
社区成员
发帖
与我相关
我的任务
分享
$s = <<<TXT
<p><img alt="" src="http://site/1.jpg" style="width: 750px; height: 500px;" /></p>
<p><img alt="" src="http://site/1.jpg" style="width: 750px; height: 500px" /></p>
<p><a style="width: 750px; height: 500px" /></p>
TXT;
echo preg_replace('/(<img[^>]+)\s+style=".+?"/s', '$1', $s);
$s = <<<'TEXT'
<p>< img alt="" src="http://site/1.jpg" style="width: 750px; height: 500px;" /></p >
<p>< img alt="" src="http://site/1.jpg" style="width: 750px; height: 500px" /></p >
<p><a style="width: 750px; height: 500px" /></p >
TEXT;
echo preg_replace ("#(<img[^>]+)(style=('|\")?[\s\S]+?\\3)#",'${1}',$s);