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);
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正则 根据自己的需求随便写个
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);
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正则 根据自己的需求随便写个
我是想输入一个匹配值,输入一个替换值就能实现这样的功能,也就是说用Matcher.replaceAll()就能实现这样的功能,不知道可不可行。