我有一个带有正则表达式的 php 代码,它在 li 标记内 p 标记的新行上失败。当我执行此代码时,它会从中删除</ul></li>
。
<?php
$data = "<h1>test</h1>
<h2>test</h2>
<p>This is not real text but just a test, This is not real text but just a test, This is not real text but just a test, This is not real text but just a test, This is not real text but just a test</p>
<ul><li><p>This is not real text but just a test, This is not real text but just a test, This is not real text but just a test, This is not real text but just a test</p>
</li></ul>
<ul><li><p>This is not real text but just a test, This is not real text but just a test, This is not real text but just a test, This is not real text but just a test</p>
</li></ul>";
$pattern = "#[\<ul\>\<li\>]*\<[p]*[h1]*[h2]*[h3]*\>(.+?)\</[p]*[h1]*[h2]*[h3]*\>[\</li\>\</ul\>]*#is";
preg_match_all($pattern, $data, $output);
var_dump($output);
?>
谁能帮我这个?