只有一个where和order by那便很简单:
  var strSQL = "select f1,f2 from t1 where f1='1' order by f2";
  var oReg = /where (.+) order by/i;
  oReg.exec(strSQL);
  var strCon = RegExp.$1;  //strCon == "f1='1'"
  strSQL = strSQL.replace(strCon, strCon + " and f2='2'");如果是多个(且不固定多少个)我也不会,高手来指点一下

解决方案 »

  1.   

    还要满足:
    1、"select * from t1 where f1='1'----->select * from t1 where f1='1' and f2='2'
    2、"select * from t1”---->select * from t1 where f2='2'
    3、"select * from t1 where f1='1' order by f2----->select * from t1 where f1='1' and f2='2' order by f2
      

  2.   

    用js正则表达式替换。
    我已经用最本的方法实现了,有一些罗嗦,看看高手们有没有更好的办法。
    先判断有没有where,然后判断有没有order by 。比较繁琐。
      

  3.   

    不太清楚你到底要实现什么??只是感觉 你要想应用正则表达式实现你的多条件查询 应该把你的条件类型 如:where f1='1',或者 where f2='2', or where f1='1' and f2='2' order by f2 的条件模式存到数组里,然后通过对数组的循环匹配,选出你用应用的sql 执行语句 !! 只是一个想法 ^_^