Skip to content

Instantly share code, notes, and snippets.

@richard-liang
Created November 19, 2015 03:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save richard-liang/3e4845adead207159bc3 to your computer and use it in GitHub Desktop.
Save richard-liang/3e4845adead207159bc3 to your computer and use it in GitHub Desktop.
Regex Test
// ....
if (reg.charAt(0) == '|' || reg.charAt(0) == '&' || reg.charAt(0) == ')') {
return false;
}
if (reg.charAt(len - 1) == '|' || reg.charAt(len - 1) == '&' || reg.charAt(len - 1) == '(') {
return false;
}
if (reg.matches(".*(<>|<&|<\\||><|>!|&>|&\\||\\|>|\\|&|!>|!&|!\\|).*")) {
return false;
}
// ....
String[] exps = verStr.split("((?<=<)|(?=<)|(?<=>)|(?=>)|(?<=\\|\\|)|(?=\\|\\|)|(?<=&&)|(?=&&)|(?=!)|(?<=!))");
List<String> splitVerStr = new ArrayList<>();
for (String s : exps) {
if (StringUtils.isEmpty(s)) {
continue;
}
if (!s.matches("!|<|>|\\|\\||&&")) {
splitVerStr.add(s);
}
}
// ....
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment