1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
|
public boolean isTwoOperatorSequence(String sentenceToTest)
{
String signe[] = {"+","-","/","*"};
int nbElement = signe.length;
int i = 0;
correspondance = false;
System.out.println(correspondance);
while(!correspondance && i < nbElement)
{
String operator_1 = signe[i];
int j = 0;
while(!correspondance && j < nbElement)
{
String operator_2 = signe[j];
String regex = "\\Q"+operator_1+operator_2+"\\E";
pattern = Pattern.compile(regex);
matcher = pattern.matcher(sentenceToTest);
correspondance = matcher.find();
j++;
}
i++;
}
return correspondance;
} |