15、骂战 (第4/5页)
stringregexcheck=“[\\(\\)\\d\\+\\-\\/\\]“;//是否是合法的表达式
072
073
if(!patternmatches(regexcheck,string))
074
returnstring;
075
076
matchermatcher=null;
077
stringtemp=““;
078
intindex=-1;
079
stringregex=“\\([\\d\\\\+\\-\\/]+\\)“;//提取括号表达式
080
string=stringrepceall(“\\s“,““);//去除空格
081
try{
082
patternpattern=patternpile(regex);
083
//循环计算所有括号里的表达式
084
while(patternmatcher(string)find()){
085
matcher=patternmatcher(string);
086
while(matcherfind()){
087
temp=matchergroup();
088
index=stringindexof(temp);
089
string=stringsubstring(0,index)
090
-->>(第4/5页)(本章未完,请点击下一页继续阅读)