Home  >  Article  >  Backend Development  >  求正则达人解决方法

求正则达人解决方法

WBOY
WBOYOriginal
2016-06-13 11:08:20880browse

求正则达人
IE浏览器下:
求正则达人解决方法alt="" src="/upload/articles/20121204/images/201212040328205506018siw5.jpg" complete="complete" data-cke-saved-src="/upload/articles/20121204/images/201212040328205506018siw5.jpg"/>

FF浏览器下:
求正则达人解决方法alt="" />

这个是用编辑器上传的图片,现在我需要把图片里面的style全部删除掉,后面的内容保持原样。求高手帮我写个正则!!
------解决方案--------------------

<br />	$str='<img   style="max-width:90%" src="/upload/articles/20121204/images/201212040328205506018siw5.jpg" complete="complete" data-cke-saved-src="/upload/articles/20121204/images/201212040328205506018siw5.jpg" alt="" />';<br />	$aa=preg_replace('/style=".*?"\s+/','',$str);<br />	echo $aa;<br />

------解决方案--------------------
$str='求正则达人解决方法';

echo preg_replace('/(求正则达人解决方法]*)style\s*=\s*"[^"]*"/i', '$1', $str);
------解决方案--------------------
#1注意:只过滤求正则达人解决方法

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn