【发布时间】:2015-01-05 06:46:48
【问题描述】:
我在一个 xml 文件中有一个 <a> 标记。我只想去除<a> 标签。
例如:
<test>This is a line with <a name="idp173968"></a> tags in it</test>
我不能用str_replace替换标签,因为<a>标签属性是多种多样的。
我试过了:
preg_replace("/<a[^>]+\>/i", "", $content);
如果标签的结构像这样<a name="idp173968"/>,它工作正常。
那么,在我的情况下如何去除标签?
预期输出:
<test>This is a line with tags in it</test>
【问题讨论】:
标签: php html regex xml preg-replace