$str = "abc [table xxx]";
echo preg_replace("#(\[\w+)( )+(\w+\])#si","\\1 \\3",$str);

解决方案 »

  1.   

    成功。谢谢。
    不过想问一下,为什么用#来开头规则?而不是/\呢?最后那个#si是什么意思?和/is有何不同?
      

  2.   

    规则最后的si 和is有何不同?
      

  3.   

    干嘛用的?
    另外,
    $str = "abc [table ]";
    echo preg_replace("#(\[\w+)( )+(\w+\])#si","\\1 \\3",$str);
    便不能替代了。
      

  4.   

    echo preg_replace("#(\[\w+)( )+(\w+\])?#si","\\1 \\3",$str);
      

  5.   

    最后一问:那个is或者si在最后是什么意思?