Home >Backend Development >PHP Tutorial > preg_replace替换a标签解决思路

preg_replace替换a标签解决思路

WBOY
WBOYOriginal
2016-06-13 13:27:201055browse

preg_replace替换a标签
更多
怎么写正则,要求a标签样式里出现display:none就把a标签替换成空

------解决方案--------------------

PHP code
$s = 更多
<a href="http://" style="line-height:27px;color:#444547;margin-right:12px;display:none">更多</a>
<a href="http://" style="line-height:27px;color:#444547;margin-right:12px;">更多</a>
TXT;
echo preg_replace('/<a>]*(?=display:none).+?/is','',$s); <div class="clear">
                 
              
              
        
            </div></a>
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