【发布时间】:2011-11-07 04:31:31
【问题描述】:
在标题中看到,这里是 HTML 代码示例:
<body>
<!--CODE_START-->
<p>I <strong>Want</strong> this</p>
<p>And this one too</p>
<!--CODE_STOP-->
<p>This sould be go to trash</p>
<!--CODE_START-->
<p>This one should be included too</p>
<!--CODE_STOP-->
问题是,我想要<!--CODE_START--> 和<!--CODE_STOP--> 中的所有内容,所以结果应该是:
<p>I <strong>Want</strong> this</p>
<p>And this one too</p>
和<p>This one should be included too</p>
我尝试将这个/<!--CODE_START-->([^<]*)<!--CODE_STOP-->/ 和/<!--CODE_START-->(.*)<!--CODE_STOP-->/ 与su、imu、im 等模式修饰符组合使用,它不起作用,只返回一个空数组。而且,我试图抓取它的完整 HTML 页面。
提前致谢。
【问题讨论】:
标签: php pcre preg-match-all