Strip BBCode via RegEx

前端 未结 1 2098
你的背包
你的背包 2020-12-22 09:41

I am trying to setup a regex that will detect [quote]???[/quote] and will remove it.

This is what I have but it is not working:

$post[\'body\'] = pre         


        
1条回答
  •  盖世英雄少女心
    2020-12-22 10:12

    Here's my test with your script:

    $text = "I am trying to setup a regex that will detect [quote]???[/quote] and will remove it.\r\nThis is what I have but it is not working:";
    $sentences = preg_replace("/\[quote\](.+?)\[\/quote\]/is", '', $text);
    echo '
    '.print_r($sentences, true).'
    ';

    And my Output:

    I am trying to setup a regex that will detect  and will remove it.
    This is what I have but it is not working:
    

    You can see: [quote]???[/quote] is removed.

    I think your problem is anywhere else. Check the Value of $post['body']!

    Maybe it is a misspelling and you meen $_POST['body']?

    0 讨论(0)
提交回复
热议问题