我有一个要求,我需要从一段文本中删除它。
<p><span> </span></p>
例如
<p><span>Because the coffee grinds stay in the pod there is virtually no cleaning either.</span></p>
<p><span> </span></p>
<p><span>Hey presto, your coffee, your way every time. </span></p>.
我已尝试删除空
<p></p>
使用正则表达式
$pattern1 = "/<p[^>]*><''/p[^>]*>/";
我应该如何修改以删除空标签
<p><span> </span></p>
如果您只需要删除这段代码,那么根本不需要regex。只需使用str_replace
进行简单的替换
$string = str_replace("<p><span> </span></p>", "", $string);