private static boolean isComplexWildcard(String pattern) { int idx1 = pattern.indexOf('['); if (idx1 != -1) { return true; } if (pattern.indexOf('?') != -1) { return true; } else { // check if the backslash escapes one of the glob special characters // if not, backslash is not part of a regex and treated literally int backSlash = pattern.indexOf('\\'); if (backSlash >= 0) { int nextIdx = backSlash + 1; if (pattern.length() == nextIdx) { return false; } char nextChar = pattern.charAt(nextIdx); if (escapedByBackslash(nextChar)) { return true; } else { return false; } } } return false; }
static String deleteBackslash(String s) { if (s.indexOf('\\') < 0) { return s; } StringBuilder sb = new StringBuilder(s.length()); for (int i = 0; i < s.length(); i++) { char ch = s.charAt(i); if (ch == '\\') { if (i + 1 == s.length()) { continue; } char next = s.charAt(i + 1); if (next == '\\') { sb.append(ch); i++; continue; } if (!escapedByBackslash(next)) { continue; } } sb.append(ch); } return sb.toString(); }
private static boolean isComplexWildcard(String pattern) { int idx1 = pattern.indexOf('['); if (idx1 != -1) { return true; } if (pattern.indexOf('?') != -1) { return true; } else { // check if the backslash escapes one of the glob special characters // if not, backslash is not part of a regex and treated literally int backSlash = pattern.indexOf('\\'); if (backSlash >= 0) { int nextIdx = backSlash + 1; if (pattern.length() == nextIdx) { return false; } char nextChar = pattern.charAt(nextIdx); if (escapedByBackslash(nextChar)) { return true; } else { return false; } } } return false; }
static String deleteBackslash(String s) { if (s.indexOf('\\') < 0) { return s; } StringBuilder sb = new StringBuilder(s.length()); for (int i = 0; i < s.length(); i++) { char ch = s.charAt(i); if (ch == '\\') { if (i + 1 == s.length()) { continue; } char next = s.charAt(i + 1); if (next == '\\') { sb.append(ch); i++; continue; } if (!escapedByBackslash(next)) { continue; } } sb.append(ch); } return sb.toString(); }
private static boolean isComplexWildcard(String pattern) { int idx1 = pattern.indexOf('['); if (idx1 != -1) { return true; } if (pattern.indexOf('?') != -1) { return true; } else { // check if the backslash escapes one of the glob special characters // if not, backslash is not part of a regex and treated literally int backSlash = pattern.indexOf('\\'); if (backSlash >= 0) { int nextIdx = backSlash + 1; if (pattern.length() == nextIdx) { return false; } char nextChar = pattern.charAt(nextIdx); if (escapedByBackslash(nextChar)) { return true; } else { return false; } } } return false; }
private static boolean isComplexWildcard(String pattern) { int idx1 = pattern.indexOf('['); if (idx1 != -1) { return true; } if (pattern.indexOf('?') != -1) { return true; } else { // check if the backslash escapes one of the glob special characters // if not, backslash is not part of a regex and treated literally int backSlash = pattern.indexOf('\\'); if (backSlash >= 0) { int nextIdx = backSlash + 1; if (pattern.length() == nextIdx) { return false; } char nextChar = pattern.charAt(nextIdx); if (escapedByBackslash(nextChar)) { return true; } else { return false; } } } return false; }
static String deleteBackslash(String s) { if (s.indexOf('\\') < 0) { return s; } StringBuilder sb = new StringBuilder(s.length()); for (int i = 0; i < s.length(); i++) { char ch = s.charAt(i); if (ch == '\\') { if (i + 1 == s.length()) { continue; } char next = s.charAt(i + 1); if (next == '\\') { sb.append(ch); i++; continue; } if (!escapedByBackslash(next)) { continue; } } sb.append(ch); } return sb.toString(); }
static String deleteBackslash(String s) { if (s.indexOf('\\') < 0) { return s; } StringBuilder sb = new StringBuilder(s.length()); for (int i = 0; i < s.length(); i++) { char ch = s.charAt(i); if (ch == '\\') { if (i + 1 == s.length()) { continue; } char next = s.charAt(i + 1); if (next == '\\') { sb.append(ch); i++; continue; } if (!escapedByBackslash(next)) { continue; } } sb.append(ch); } return sb.toString(); }