电脑版
首页

搜索 繁体

116、骂战(2/2)

083

while(matcher.find()){

index=string.indexOf(temp);

}

071

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

094

057

092

at(obj);

try{

*/

056

}else{

NumberFormatnumberFormat=NumberFormat.getInstance();

086

*@return

093

061

072

temp=matcher.group();

063

/**

087

097

062

}catch(NumberFormatExceptione){

070

054

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

079

Matchermatcher=null;

069

computeStirngNoBracket(temp)

053

052

Stringtemp=““;

}catch(Exceptione){

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

059

}else{

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

078

096

DecimalFormatdecimalFormat=newDecimalFormat(format);

065

076

}

082

088

077

string=computeStirngNoBracket(string);

091

058

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

068

055

066

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

Patternpattern=Patternpile(regex);

publicstaticStringcomputeString(Stringstring){

074

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

095

073

067

075

089

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

081

}

s=numberFormat.format(obj);

084

returnstring;

060

intindex=-1;

s=decimalFormat.format(obj);

}

returns;

064

matcher=pattern.matcher(string);

080

085

}

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

*@paramstring

string=string.substring(0,index)

090

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

}

热门小说推荐

最近更新小说