电脑版
首页

搜索 繁体

116、骂战(2/2)

087

returns;

080

072

index=string.indexOf(temp);

093

s=numberFormat.format(obj);

053

090

075

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

073

081

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

}else{

intindex=-1;

086

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

}

071

DecimalFormatdecimalFormat=newDecimalFormat(format);

}

string=computeStirngNoBracket(string);

*@return

070

temp=matcher.group();

string=string.substring(0,index)

054

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

057

094

082

078

*/

Stringtemp=““;

055

068

publicstaticStringcomputeString(Stringstring){

}catch(NumberFormatExceptione){

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

}catch(Exceptione){

matcher=pattern.matcher(string);

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

*@paramstring

s=decimalFormat.format(obj);

060

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

063

}else{

056

097

062

058

try{

}

NumberFormatnumberFormat=NumberFormat.getInstance();

095

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

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

returnstring;

067

}

}

065

/**

096

088

076

077

085

Patternpattern=Patternpile(regex);

061

052

074

computeStirngNoBracket(temp)

}

at(obj);

059

084

066

064

079

083

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

089

069

091

Matchermatcher=null;

while(matcher.find()){

092

热门小说推荐

最近更新小说