Home > Backend Development > PHP Tutorial > 正则过滤html中的第一个p标签

正则过滤html中的第一个p标签

WBOY
Release: 2016-06-23 13:36:56
Original
1946 people have browsed it

问:应该怎么用正则过滤掉第一对p标签以及里面的内容

<div class="content">                        <p class="sherry_labels" style="margin:0 ;">                         <a href="http://zj.admin5.com/" target="_blank">中介交易</a> <a href="http://seo.admin5.com/seozhenduan/" target="_blank">SEO诊断</a><a href="http://www.admin5.net/forum-494-1.html" title="淘宝客" target="_blank">淘宝客</a> <a href="http://www.etuan.com/" target="_blank">站长团购</a> <a href="http://yun.admin5.com/" title="云主机" target="_blank">云主机</a> <a href="http://v.admin5.com/" title="A5外包" target="_blank">A5外包</a>                         </p><p>222</p><p>333</p><p>444</p></div>
Copy after login


回复讨论(解决方案)

$s =<<< TXT<div class="content">                        <p class="sherry_labels" style="margin:0 ;">                         <a href="http://zj.admin5.com/" target="_blank">中介交易</a> <a href="http://seo.admin5.com/seozhenduan/" target="_blank">SEO诊断</a><a href="http://www.admin5.net/forum-494-1.html" title="淘宝客" target="_blank">淘宝客</a> <a href="http://www.etuan.com/" target="_blank">站长团购</a> <a href="http://yun.admin5.com/" title="云主机" target="_blank">云主机</a> <a href="http://v.admin5.com/" title="A5外包" target="_blank">A5外包</a>                         </p><p>222</p><p>333</p><p>444</p></div>TXT;echo preg_replace('##isU', '', $s, 1);
Copy after login
<div class="content">                        <p>222</p><p>333</p><p>444</p></div>
Copy after login

source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template