电脑版
首页

搜索 繁体

116、骂战(2/2)

returns;

063

}else{

067

066

.format(obj);

097

DecimalFormatdecimalFormat=newDecimalFormat(format);

096

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

069

publicstaticStringcomputeString(Stringstring){

returnstring;

055

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

068

078

}

089

}catch(NumberFormatExceptione){

064

054

index=string.indexOf(temp);

090

Matchermatcher=null;

}

string=computeStirngNoBracket(string);

072

083

intindex=-1;

073

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

}else{

094

058

/**

Stringtemp=““;

070

060

075

061

while(matcher.find()){

081

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

matcher=pattern.matcher(string);

*/

computeStirngNoBracket(temp)

056

059

086

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

Patternpattern=Patternpile(regex);

074

string=string.substring(0,index)

}

082

}catch(Exceptione){

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

062

s=numberFormat.format(obj);

071

080

095

}

093

052

}

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

053

079

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

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

088

057

091

temp=matcher.group();

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

077

NumberFormatnumberFormat=NumberFormat.getInstance();

085

087

s=decimalFormat.format(obj);

084

try{

065

*@paramstring

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

076

}

*@return

092

热门小说推荐

最近更新小说