Home > Backend Development > PHP Tutorial > 正则过滤html中的第一个p标签,该怎么处理

正则过滤html中的第一个p标签,该怎么处理

WBOY
Release: 2016-06-13 12:17:54
Original
1581 people have browsed it

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

<br /><div class="content"><br />                        <p class="sherry_labels" style="margin:0 ;"> <br />                        <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><br />                         </p><br /><p>222</p><p>333</p><p>444</p><br /></div><br />
Copy after login

------解决思路----------------------
$s =<<< TXT<br /><div class="content"><br />                        <p class="sherry_labels" style="margin:0 ;"> <br />                        <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><br />                         </p><br /><p>222</p><p>333</p><p>444</p><br /></div><br />TXT;

echo preg_replace('##isU', '', $s, 1);
Copy after login
<div class="content"><br />                        <br /><p>222</p><p>333</p><p>444</p><br /></div><br />
Copy after login

Related labels:
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