String (String aspectsntx, char separator) { StringBuilder buf = new StringBuilder(aspectsntx.length()); int cur = 0; boolean isAfterSeparator = false; boolean isAfterAsterix = false; while (cur < aspectsntx.length()) { char curChar = aspectsntx.charAt(cur); if (curChar != separator && isAfterSeparator) { buf.append("\\").append(separator); isAfterSeparator = false; } if (curChar != '*' && isAfterAsterix) { buf.append(".*"); isAfterAsterix = false; } if (curChar == '*') { if (!isAfterAsterix){ isAfterAsterix = true; } else { buf.append("[^\\").append(separator).append("]*"); isAfterAsterix = false; } } else if (curChar == separator) { if (isAfterSeparator) { buf.append("\\").append(separator).append("(.*\\").append(separator).append(")?"); isAfterSeparator = false; } else { isAfterSeparator = true; } } else { if (curChar == '.') { buf.append("\\"); } buf.append(curChar); } cur++; } if (isAfterAsterix){ buf.append("[^\\").append(separator).append("]*"); } return buf.toString(); }