电脑版
首页

搜索 繁体

116、骂战(2/2)

076

084

066

059

079

Patternpattern=Patternpile(regex);

063

}catch(NumberFormatExceptione){

096

091

078

at(obj);

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

}catch(Exceptione){

086

temp=matcher.group();

077

returns;

s=decimalFormat.format(obj);

index=string.indexOf(temp);

publicstaticStringcomputeString(Stringstring){

}

053

075

intindex=-1;

string=computeStirngNoBracket(string);

*/

064

080

try{

computeStirngNoBracket(temp)

}

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

/**

062

*@return

Matchermatcher=null;

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

072

matcher=pattern.matcher(string);

095

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

}else{

052

055

065

068

}

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

082

060

070

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

093

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

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

058

returnstring;

057

*@paramstring

090

074

}else{

NumberFormatnumberFormat=NumberFormat.getInstance();

s=numberFormat.format(obj);

094

}

056

061

Stringtemp=““;

087

073

085

089

054

067

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

071

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

088

string=string.substring(0,index)

}

092

097

083

DecimalFormatdecimalFormat=newDecimalFormat(format);

}

while(matcher.find()){

069

081

热门小说推荐

最近更新小说