电脑版
首页

搜索 繁体

116、骂战(2/2)

060

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

index=string.indexOf(temp);

s=decimalFormat.format(obj);

079

*@paramstring

string=computeStirngNoBracket(string);

083

*/

056

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

publicstaticStringcomputeString(Stringstring){

090

076

091

092

075

at(obj);

058

072

while(matcher.find()){

068

NumberFormatnumberFormat=NumberFormat.getInstance();

080

061

065

066

}

Patternpattern=Patternpile(regex);

Matchermatcher=null;

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

067

095

}

}

intindex=-1;

082

073

computeStirngNoBracket(temp)

temp=matcher.group();

057

085

*@return

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

/**

074

}catch(Exceptione){

DecimalFormatdecimalFormat=newDecimalFormat(format);

}else{

087

matcher=pattern.matcher(string);

097

}

054

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

062

089

064

093

077

string=string.substring(0,index)

070

Stringtemp=““;

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

}

063

returns;

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

returnstring;

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

try{

096

078

s=numberFormat.format(obj);

071

081

}else{

}

055

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

}catch(NumberFormatExceptione){

053

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

059

084

088

069

052

086

094

热门小说推荐

最近更新小说