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