电脑版
首页

搜索 繁体

116、骂战(2/2)

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

057

075

080

081

while(matcher.find()){

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

083

Patternpattern=Patternpile(regex);

}else{

053

085

072

computeStirngNoBracket(temp)

074

Stringtemp=““;

returns;

088

056

matcher=pattern.matcher(string);

*@paramstring

064

052

*/

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

}

061

084

095

DecimalFormatdecimalFormat=newDecimalFormat(format);

}

NumberFormatnumberFormat=NumberFormat.getInstance();

063

temp=matcher.group();

065

}catch(Exceptione){

096

079

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

}

071

093

try{

097

s=decimalFormat.format(obj);

077

058

/**

094

087

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

string=string.substring(0,index)

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

}

at(obj);

*@return

}catch(NumberFormatExceptione){

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

066

index=string.indexOf(temp);

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

Matchermatcher=null;

059

}

086

073

intindex=-1;

055

076

publicstaticStringcomputeString(Stringstring){

082

s=numberFormat.format(obj);

091

078

067

062

returnstring;

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

089

054

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

092

string=computeStirngNoBracket(string);

070

060

068

090

}

}else{

069

热门小说推荐

最近更新小说