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