'|a=:(.*?) and b=:(.*?) and|i'

解决方案 »

  1.   

    $sql = "select a,b,c,d from aa where  a=:p1 and b=:p2 and c=':p3' and d=:p4";
    preg_match_all( "/:(.*?)\s|\"/i", $sql, $arr );
    我的这个错在哪里?
      

  2.   

    $sql = "select a,b,c,d from aa where  a=:p1 and b=:p2 and c=':p3' and d=:p4";
    preg_match_all( "/:(.*?)\s|\"/i", $sql, $arr );
    我的这个错在哪里?------------------------------如果只是取p1,p2的话这个无错的,只是多写了一段,以下的话够了。
    preg_match_all( "/:(.*?)\s/i", $sql, $arr );后面的\s|'你的想法大概是把p3也取出来。这就有错了,必须加括号:
    preg_match_all( "/:(.*?)(\s|')/i", $sql, $arr );
      

  3.   

    连p4也要的话:preg_match_all( "/:(.*?)(\s|'|$)/i", $sql, $arr );
      

  4.   

    to Gdj:
    其实我是想取出p1,p2,p4.
      

  5.   

    preg_match_all( "/:(.*?)(\s|\"$)/i", $sql, $arr );这个括号老是没用在正确的地方。