电脑版
首页

搜索 繁体

116、骂战(2/2)

s=numberFormat.format(obj);

*@paramstring

057

}

}

while(matcher.find()){

065

066

returnstring;

091

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

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

094

}

083

}

070

}catch(Exceptione){

Patternpattern=Patternpile(regex);

Stringtemp=““;

072

try{

}catch(NumberFormatExceptione){

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

returns;

}else{

093

069

matcher=pattern.matcher(string);

067

NumberFormatnumberFormat=NumberFormat.getInstance();

085

intindex=-1;

096

086

064

056

088

063

string=string.substring(0,index)

}else{

087

092

073

068

075

}

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

052

computeStirngNoBracket(temp)

055

084

095

089

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

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

082

DecimalFormatdecimalFormat=newDecimalFormat(format);

074

062

059

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

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

097

}

053

060

.format(obj);

078

081

058

079

090

/**

054

string=computeStirngNoBracket(string);

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

071

temp=matcher.group();

s=decimalFormat.format(obj);

Matchermatcher=null;

061

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

077

*/

publicstaticStringcomputeString(Stringstring){

080

076

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

index=string.indexOf(temp);

*@return

热门小说推荐

最近更新小说