public static void main(String[] args) {
String returnStr="10%";
String reg = "^([0-9.]+)[ ]*%$";
if((reg)){
("是");
}else{
("不是");
}
}
后台写法:
String reg = "^([0-9.]+)[ ]*%$"; //注意编码下的% ( %% )有可能不一致 把页面返回来的%复制在"^([0-9.]+)[ ]*%$"就可以了
String test= (String) ("test");
if(!(reg)){ //test代表返回的百分比参数
return"百分比格式错误!";
}
//如果返回来的是多个百分比就循环
String[] str = ("\\,");
for(int z=0;z
if(!str[z].matches(reg)){
return"百分比格式错误!";
}
}