我想检查是否有双重运算符。例如 :
整数结果 = x+y;
结果operatorCounter = 2,它正在工作。但:
for(;i<size;i++)
结果operatorCounter = 3应该是operatorCounter = 2。
我的正则表达式String doubleOperatorPattern = "\'.\\++\'";
我想要的运算符: (++) (--) (==) (&&) (||)
public void findOperator(String file){
String operatorPattern = "['+''-''*''/''=''<''>''<=''>=''&''|''^''!''\\-?']";
Pattern pattern = Pattern.compile(operatorPattern);
Matcher matcher = pattern.matcher(file);
while (matcher.find()) {
operatorCounter++;
}
String doubleOperatorPatternString = "['==''++''--''&&''||']";
Pattern doubleOperatorPattern =
Pattern.compile(doubleOperatorPatternString);
Matcher doubleOperatorMatcher = doubleOperatorPattern.matcher(file);
while(doubleOperatorMatcher.find()){
operatorCounter--;
}
}
青春有我
料青山看我应如是
随时随地看视频慕课网APP
相关分类