电脑版
首页

搜索 繁体

116、骂战(2/2)

temp=matcher.group();

087

}

079

070

}

string=string.substring(0,index)

090

094

052

081

index=string.indexOf(temp);

075

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

}catch(Exceptione){

}

computeStirngNoBracket(temp)

095

069

063

}

064

}else{

083

065

while(matcher.find()){

071

Matchermatcher=null;

055

060

Stringtemp=““;

058

s=numberFormat.format(obj);

Patternpattern=Patternpile(regex);

074

returns;

088

076

publicstaticStringcomputeString(Stringstring){

057

string=computeStirngNoBracket(string);

NumberFormatnumberFormat=NumberFormat.getInstance();

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

082

068

086

078

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

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

matcher=pattern.matcher(string);

085

DecimalFormatdecimalFormat=newDecimalFormat(format);

072

*@return

}catch(NumberFormatExceptione){

}

061

077

093

062

intindex=-1;

}

066

*@paramstring

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

096

080

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

*/

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

054

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

059

092

s=decimalFormat.format(obj);

097

067

}else{

073

084

091

try{

at(obj);

089

returnstring;

056

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

/**

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

053

热门小说推荐

最近更新小说