【发布时间】:2013-06-03 23:50:27
【问题描述】:
我正在尝试从来自 Wordpress 生成的数据库的文本字符串中删除一些 html。
我想要这个:
Marnie Stanton led us through the process first and then everyone went crazy.
[caption id="attachment_76" align="alignnone" width="191"] One of the work stations[/caption]
[caption id="attachment_78" align="alignnone" width="300"] The group is getting some great results[/caption]
[caption id="attachment_83" align="alignnone" width="224"] You can see the prints multiplying[/caption]
变成这样:
Marnie Stanton led us through the process first and then everyone went crazy.
所以我想要的是从第一个 [caption] 到最后一个 [/caption] 的所有内容。
我是从这个开始的:
(\[caption\s+?[^]]+\])
只删除第一个标签。
【问题讨论】:
-
Anne surprises herself ...文本怎么样,应该在结果中吗? -
哦,实际上不应该是这样,但这只是如何将其添加到 wordpress 博客的问题,因此对于编写正则表达式的所有目的,它应该仍然存在。
-
我把它从问题中删除了,所以也没有更多的混乱。