Update RegexSelector.java

master
zhuyue 2017-05-03 18:24:19 +08:00 committed by GitHub
parent cbf80af5dd
commit c3183252ac
1 changed files with 8 additions and 18 deletions

View File

@ -45,24 +45,14 @@ public class RegexSelector implements Selector {
} }
private boolean hasGroup(String regexStr) { private boolean hasGroup(String regexStr) {
if (StringUtils.countMatches(regexStr, "(") - StringUtils.countMatches(regexStr, "\\(") == int x = StringUtils.countMatches(regexStr, "(") - StringUtils.countMatches(regexStr, "\\(");
StringUtils.countMatches(regexStr, "(?:") - StringUtils.countMatches(regexStr, "\\(?:")){ int a = StringUtils.countMatches(regexStr, "(?:") - StringUtils.countMatches(regexStr, "\\(?:");
return false; int b = StringUtils.countMatches(regexStr, "(?=") - StringUtils.countMatches(regexStr, "\\(?=");
} int c = StringUtils.countMatches(regexStr, "(?<") - StringUtils.countMatches(regexStr, "\\(?<");
if (StringUtils.countMatches(regexStr, "(") - StringUtils.countMatches(regexStr, "\\(") == int d = StringUtils.countMatches(regexStr, "(?!") - StringUtils.countMatches(regexStr, "\\(?!");
StringUtils.countMatches(regexStr, "(?=") - StringUtils.countMatches(regexStr, "\\(?=") ) { int e = StringUtils.countMatches(regexStr, "(?#") - StringUtils.countMatches(regexStr, "\\(?#");
return false;
} if (x == (a + b + c + d + e)) {
if (StringUtils.countMatches(regexStr, "(") - StringUtils.countMatches(regexStr, "\\(") ==
StringUtils.countMatches(regexStr, "(?<") - StringUtils.countMatches(regexStr, "\\(?<") ) {
return false;
}
if (StringUtils.countMatches(regexStr, "(") - StringUtils.countMatches(regexStr, "\\(") ==
StringUtils.countMatches(regexStr, "(?!") - StringUtils.countMatches(regexStr, "\\(?!") ) {
return false;
}
if (StringUtils.countMatches(regexStr, "(") - StringUtils.countMatches(regexStr, "\\(") ==
StringUtils.countMatches(regexStr, "(?#") - StringUtils.countMatches(regexStr, "\\(?#") ) {
return false; return false;
} }
return true; return true;