电脑版
首页

搜索 繁体

116、骂战(2/2)

070

NumberFormatnumberFormat=NumberFormat.getInstance();

082

061

085

*@return

054

094

}

077

068

072

/**

052

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

096

Stringtemp=““;

s=decimalFormat.format(obj);

067

index=string.indexOf(temp);

084

093

returnstring;

本章已阅读完毕(请击下一章继续阅读!)

095

057

092

074

069

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

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

Matchermatcher=null;

079

}else{

}

091

073

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

publicstaticStringcomputeString(Stringstring){

DecimalFormatdecimalFormat=newDecimalFormat(format);

056

}catch(Exceptione){

returns;

075

computeStirngNoBracket(temp)

083

string=computeStirngNoBracket(string);

*@paramstring

062

053

087

intindex=-1;

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

065

matcher=pattern.matcher(string);

088

086

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

}

}

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

while(matcher.find()){

}

076

059

064

055

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

}catch(NumberFormatExceptione){

}

078

try{

097

*/

Patternpattern=Patternpile(regex);

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

060

080

temp=matcher.group();

058

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

066

s=numberFormat.format(obj);

081

.format(obj);

063

090

089

string=string.substring(0,index)

071

}else{

热门小说推荐

最近更新小说