&nrat.foratobj;
059
}
060
&nne{
061
}
062
returns;
063
}
064
065
/
066
计算字符串四则运算表达式
067
&n
068
return
069
/
070
publicstaticStrputeStrgStrgstrg{
071
&nrexCheck“\\\\\\d\\+\\\\/\\.“;//是否是合法的表达式
072
073
if!Pattern.atchesrexCheck,strg
074
&n;
075
076
Matcheratchernull;
077
&ntep““;
078
tdex1;
079
&nrex“\\\\d\\.\\+\\\\/+\\“;//提取括号表达式
080
&nstrg.receAll“\\s“,““;//去除空格
081
try{
082
PatternpatternPatternpilerex;
083
//循环计算所有括号里的表达式
084
hilepattern.atcherstrg.fd{
085
atcherpattern.atcherstrg;
086
hileatcher.fd{
087
&nup;
088
&n.dexOftep;
089
&nstrg.su0,dex
090
&nBrackettep
091
&n.sudex+tep.lenh;
092
}
093
}
094
//最后计算总的表达式结果
095
&n;
096
&nratExceptione{
097
&Messa;未完待续。