String sql="from User full  outer join Book where username=' where is '' order by ' order by User.userId desc";求一正则表达式,将单引号之间的数据替换为?,连续的两个单引号不处理String result=sql.replaceAll(正则表达式,"?");result结果为: from User full  outer join Book where username=? order by User.userId desc

解决方案 »

  1.   

    String sql="from User full  outer join Book where username=' where is '' order by ' order by User.userId desc"; 求一正则表达式,将单引号之间的数据替换为?,连续的两个单引号不处理 String result=sql.replaceAll(正则表达式,"?"); result结果为: from User full  outer join Book where username=? order by User.userId desc
    这里应该为:' where is ' 吧???LZ是不是写错了
      

  2.   

    String regex = "'(?:[^']|'')*'";
    System.out.println(sql.replaceAll(regex, "?"));
      

  3.   

    没有写错的哦,我在做一个SQL解析的东东
    估意将条件写成 ' where is '' order by '的这个与需要的正则表达式没啥关系的,哈