PHP preg_replace不替换html的标记内容

时间:2017-12-29 00:33:00

标签: php html regex svg preg-replace

我尝试使用preg_replace删除所有SVG标记内容,但无论我如何尝试都无法正常工作。

我正在尝试这样的事情:

$tmp=preg_replace("/(?<=<svg )(.*)(?=\\\/svg>)/", "", $tmp);

其中$ tmp是:

"svg":"<svg xmlns="http:\/\/www.w3.org\/2000\/svg" xml:space="preserve" width="269" height="264" preserveAspectRatio="none" xmlns:xlink="http:\/\/www.w3.org\/1999\/xlink"><g><image x="0" y="0" width="269" height="264" preserveAspectRatio="none" ><\/image><\/g><\/svg>"

结果显示:

"svg": "<svg \/svg>"

或类似的东西。我需要它用于下一个json_decode。

但我看到的结果是:

1)什么都没做

2)警告:preg_replace():未知的修饰符&#39; v&#39;

然而,它适用于在线编辑器。我究竟做错了什么?

0 个答案:

没有答案
相关问题