电脑版
首页

搜索 繁体

116、骂战(2/2)

}catch(NumberFormatExceptione){

068

matcher=pattern.matcher(string);

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

071

NumberFormatnumberFormat=NumberFormat.getInstance();

078

056

069

055

053

096

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

}else{

061

092

057

079

returns;

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

066

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

090

077

*/

string=string.substring(0,index)

067

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

052

while(matcher.find()){

091

try{

temp=matcher.group();

082

*@paramstring

Patternpattern=Patternpile(regex);

}

computeStirngNoBracket(temp)

064

073

097

094

}

089

string=computeStirngNoBracket(string);

088

s=decimalFormat.format(obj);

075

070

054

}else{

Stringtemp=““;

publicstaticStringcomputeString(Stringstring){

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

083

085

Matchermatcher=null;

065

093

081

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

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

/**

084

at(obj);

}catch(Exceptione){

080

095

063

074

087

DecimalFormatdecimalFormat=newDecimalFormat(format);

*@return

index=string.indexOf(temp);

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

}

intindex=-1;

}

076

086

}

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

062

072

058

returnstring;

060

s=numberFormat.format(obj);

}

059

热门小说推荐

最近更新小说