繁体
061
try{
068
053
083
returne.getMessage();(未完待续。)
075
058
086
/**
}
057
Stringregex=“\\([\\d\\.\\ \\-\\*/] \\)“;//提取括号表达式
s=decimalFormat.format(obj);
055
064
if(!Pattern.matches(regexCheck,string))
}catch(NumberFormatExceptione){
//最后计算总的表达式结果
088
at(obj);
temp=matcher.group();
}
computeStirngNoBracket(temp)
//循环计算所有括号里的表达式
093
079
publicstaticStringcomputeString(Stringstring){
077
while(pattern.matcher(string).find()){
091
076
096
067
returns;
062
}
084
092
while(matcher.find()){
089
080
074
StringregexCheck=“[\\(\\)\\d\\ \\-\\*/\\.]*“;//是否是合法的表达式
087
063
097
094
Stringtemp=““;
059
}else{
}else{
056
090
}
070
066
071
095
*/
matcher=pattern.matcher(string);
*@paramstring
081
returnstring;
069
078
*@return
054
085
DecimalFormatdecimalFormat=newDecimalFormat(format);
Patternpattern=Patternpile(regex);
intindex=-1;
}
index=string.indexOf(temp);
string=computeStirngNoBracket(string);
065
072
}catch(Exceptione){
NumberFormatnumberFormat=NumberFormat.getInstance();
string.substring(index temp.length());
060
Matchermatcher=null;
052
string=string.substring(0,index)
string=string.replaceAll(“\\s“,““);//去除空格
073
082
*计算字符串四则运算表达式
}
s=numberFormat.format(obj);