【发布时间】:2024-05-19 07:35:02
【问题描述】:
我无法确定如何执行此操作,我有一个字符串看起来像这样......
$text = "<p>This is some example text This is some example text This is some example text</p>
<p><em>This is some example text This is some example text This is some example text</em></p>
<p>This is some example text This is some example text This is some example text</p>";
我基本上想使用 preg_repalce 和 regex 之类的东西来删除
<em>This is some example text This is some example text This is some example text</em>
所以我需要编写一些 PHP 代码来搜索开始 <em> 和结束 </em> 并删除中间的所有文本
希望有人可以提供帮助, 谢谢。
【问题讨论】:
-
字符串是否总是只包含一组 标签?
-
然后有空的
<p>元素? -
是的,他们总是在那里,是的,我最终会得到一个空的
但这不是问题
标签: php regex string preg-replace