电脑版
首页

搜索 繁体

116、骂战(2/2)

071

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

075

063

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

}

}

061

s=numberFormat.format(obj);

054

072

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

091

returnstring;

string=string.substring(0,index)

*/

053

}

092

Matchermatcher=null;

087

093

082

069

086

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

matcher=pattern.matcher(string);

s=decimalFormat.format(obj);

064

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

059

084

DecimalFormatdecimalFormat=newDecimalFormat(format);

computeStirngNoBracket(temp)

Stringtemp=““;

077

083

095

returns;

094

at(obj);

temp=matcher.group();

057

index=string.indexOf(temp);

}else{

Patternpattern=Patternpile(regex);

*@paramstring

058

073

}else{

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

}

while(matcher.find()){

062

NumberFormatnumberFormat=NumberFormat.getInstance();

055

088

067

076

try{

}catch(Exceptione){

097

060

079

078

}catch(NumberFormatExceptione){

}

074

intindex=-1;

068

089

/**

096

080

string=computeStirngNoBracket(string);

070

090

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

publicstaticStringcomputeString(Stringstring){

*@return

085

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

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

}

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

052

065

066

081

056

热门小说推荐

最近更新小说