preg_replace未知修饰符

时间:2011-12-29 12:06:32

标签: php preg-replace

<?php
$str= <<<HTML
<div class="spoiler"><span class="trigger"><img src="/images/tree/plus.gif" /><a href="#">Filejungle</a></span>
    <div style="display: none">Content
</div>
</div><br/>
<br/>
HTML;

$str = preg_replace("#<span class=\"trigger\"\>\<img src=\"/images/tree/plus.gif\" /><a href=\"#\">(.*)\</a\>\</span\>#s", "", $str);
echo $str;
?>
  

警告:preg_replace()[function.preg-replace]:未知修饰符....

我如何纠正?

1 个答案:

答案 0 :(得分:1)

您的分隔符为#,但您也在<a href中使用了分隔符。逃避它。

$str = preg_replace("#<span class=\"trigger\"\>\<img src=\"/images/tree/plus.gif\" /><a href=\"\#\">(.*)\</a\>\</span\>#s", "", $str);