str = "d=[ddd] and c={aaa} or g=[ccc]";
str = str.replace(/\[|\]/gi,"'").replace(/\{|\}/gi,"%");

解决方案 »

  1.   

    str_replace("[","'",$str);
    等等……
      

  2.   

    我要替换[]你还让我写
    str_replace("[","'",$str);str_replace("]","'",$str);
    我累不累哦
      

  3.   

    原始办法:
    $str="[ddd] and c={aaa} or g=[ccc]";$a = array("/\[/","/\]/","/\{/","/\}/");
    $b= array("'","'","%","%");$str = preg_replace($a,$b,$str);
      

  4.   

    我发的是没问题的,是你不懂用吧。var str = "d=[ddd] and c={aaa} or g=[ccc]";
    str = str.replace(/\[|\]/gi,"'").replace(/\{|\}/gi,"%");
      

  5.   

    Amwpfiqvy发的是JS的
    先看懂了再说~
      

  6.   

    function magicStr($str)
    {
      return strtr($str,"[]{}","''%%");
    }