代码之家  ›  专栏  ›  技术社区  ›  Harea Costicla

从am字符串中删除[caption][/caption]

  •  0
  • Harea Costicla  · 技术社区  · 9 年前

    假设我有绳子

    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'])

    你能帮我吗?提前谢谢,对不起我的英语

    1 回复  |  直到 9 年前
        1
  •  1
  •   Thomas Ayoub    9 年前

    将其更改为:

    /\\[caption.*?\\].*\\[.caption\\]/
    

    这将删除所有介于 [caption] [/caption]