从字符串中删除 [caption][/caption]
Remove [caption][/caption] from am string
假设我有字符串
test [caption id="attachment_13399" align="alignleft" width="240"]<img class="img" src="test.jpg" alt="Test Image" width="240" height="270" /> Test remove capture[/caption] end test
我只需要在 preg_replace 之后显示:test end test
但我得到 test Test remove capture end test
。
我的正则表达式是:$text = preg_replace('/\[.*?\]/', '', $a_record['content'])
你能帮帮我吗?提前致谢,对不起我的英语
改为:
/\[caption.*?\].*\[.caption\]/
这将删除 [caption]
和 [/caption]
之间的所有内容
假设我有字符串
test [caption id="attachment_13399" align="alignleft" width="240"]<img class="img" src="test.jpg" alt="Test Image" width="240" height="270" /> Test remove capture[/caption] end test
我只需要在 preg_replace 之后显示:test end test
但我得到 test Test remove capture end test
。
我的正则表达式是:$text = preg_replace('/\[.*?\]/', '', $a_record['content'])
你能帮帮我吗?提前致谢,对不起我的英语
改为:
/\[caption.*?\].*\[.caption\]/
这将删除 [caption]
和 [/caption]