电脑版
首页

搜索 繁体

116、骂战(2/2)

}catch(NumberFormatExceptione){

088

063

089

s=numberFormat.format(obj);

matcher=pattern.matcher(string);

try{

string=computeStirngNoBracket(string);

StringregexCheck=“[\\(\\)\\d\\ \\-\\*/\\.]*“;//是否是合法的表达式

}

Stringtemp=““;

062

081

}

076

055

returnstring;

}catch(Exceptione){

computeStirngNoBracket(temp)

069

090

087

DecimalFormatdecimalFormat=newDecimalFormat(format);

//循环计算所有括号里的表达式

Patternpattern=Patternpile(regex);

077

054

058

072

078

053

075

if(!Pattern.matches(regexCheck,string))

080

NumberFormatnumberFormat=NumberFormat.getInstance();

056

071

//最后计算总的表达式结果

064

.format(obj);

059

while(pattern.matcher(string).find()){

returns;

083

061

085

}else{

092

067

intindex=-1;

096

string=string.substring(0,index)

052

*计算字符串四则运算表达式

*/

091

095

066

*@paramstring

079

Stringregex=“\\([\\d\\.\\ \\-\\*/] \\)“;//提取括号表达式

/**

086

}

Matchermatcher=null;

068

}

073

index=string.indexOf(temp);

*@return

temp=matcher.group();

publicstaticStringcomputeString(Stringstring){

本章已阅读完毕(请击下一章继续阅读!)

093

070

}

074

094

returne.getMessage();(未完待续。)

}else{

057

string=string.replaceAll(“\\s“,““);//去除空格

097

string.substring(index temp.length());

while(matcher.find()){

065

082

060

s=decimalFormat.format(obj);

084

}

热门小说推荐

最近更新小说