本帖最后由 java2000_net 于 2008-08-05 15:57:17 编辑

解决方案 »

  1.   


    String s = "dbid = new String(dbid.getBytes(\"ISO8859-1\"),\"GBK\")";
    int m = s.indexOf("getBytes(\"ISO8859-1\")");
    if(m != -1){
    s = "dbid = antiInject(new String(dbid.getBytes(\"ISO8859-1\"),\"GBK\"))";
    }
    System.out.println(s);
      

  2.   

    String reg = "([a-zA-Z0-9_])+ *= *(new +String\(.*getBytes(\"ISO8859-1\"),.*\))"
    String s =exp
    Pattern p = Pattern.complie(reg);
    Matcher m = p.match(s)
    if(m.match()){
       s = m.group(1)+"=antiInject("+m.group(2)+")";
       or s.replace(m.group(2),"antiInject("+m.group(2)+")");
    }自己查下java正则 根据自己的需求随便写个
      

  3.   

    很感谢您的回复。
    我是想输入一个匹配值,输入一个替换值就能实现这样的功能,也就是说用Matcher.replaceAll()就能实现这样的功能,不知道可不可行。