【发布时间】:2018-12-22 10:24:40
【问题描述】:
如何替换分隔符之间的所有<p> 标签?我的文字是
<p>other text...</p>
<p>other text...</p>
``text text...</p>
<p>text text...</p>
<p>text text ...``
<p>other text...</p>
<p>other text...</p>
``text text...</p>
<p>text text...</p>
<p>text text ...``
<p>other text...</p>
<p>other text...</p>
``text text...</p>
<p>text text...</p>
<p>text text ...``
<p>other text...</p>
<p>other text...</p>
我想匹配双反引号之间的所有<p> 标记(``此处的所有 p 标记``)作为分隔符,并用空字符串替换它们。如果使用正则表达式 /<\/?p>/i 在分隔符之外没有其他文本,我可以匹配 p 标签,但是如果在分隔符之外有文本和其他 p 标签,我如何匹配分隔符内的所有 p 标签。
【问题讨论】:
-
尝试使用
''\w*/<\?p>/i\w*'' -
@DigvijaysinhGohil 这个正则表达式根本不起作用。
标签: php regex preg-replace preg-replace-callback