修复参数替换函数带\"的时候产生的bug

This commit is contained in:
seagull 2017-12-13 19:26:33 +08:00
parent 61e8e97987
commit eb52bb08d8
1 changed files with 7 additions and 0 deletions

View File

@ -24,6 +24,7 @@ public class ChangString {
str = str.replaceAll("'", "\'");
//@@用来注释@的引用作用
int varcount=counter(str,"@")-counter(str,"@@")*2;
//如果存在传参进行处理
if(varcount>0){
luckyclient.publicclass.LogUtil.APP.info(""+changname+""+str+"】中找到"+varcount+"个可替换参数");
@ -34,6 +35,9 @@ public class ChangString {
if(str.indexOf("@@"+entry.getKey())>-1){
str=str.replaceAll("@@"+entry.getKey(), "////CHANG////");
}
//用来替换字符串中带了\"或是\'会导致\消失的问题
entry.setValue(entry.getValue().replaceAll("\\\\\"", "\\""));
entry.setValue(entry.getValue().replaceAll("\\\\\'", "\\\\'"));
int viewcount=counter(str,"@"+entry.getKey());
str=str.replaceAll("@"+entry.getKey(), entry.getValue());
luckyclient.publicclass.LogUtil.APP.info(""+changname+"引用变量【@"+entry.getKey()+"】替换成值【"+entry.getValue()+"");
@ -47,6 +51,9 @@ public class ChangString {
}
}
str=str.replaceAll("@@","@");
//用来恢复字符串中带了\"或是\'会导致\消失的问题
str = str.replaceAll("\\"", "\\\\\"");
str = str.replaceAll("\\'", "\\\\\'");
return str;
}catch(Exception e){
e.printStackTrace();