String (String string) { return string == null ? null : string.replaceAll("\\.", "\\.") // "." -> "\." .replaceAll("\\*", ".*") // "*" -> ".*" .replaceAll("\\?", ".") // "?" -> "." .replaceAll(",\\s*", "|"); // "," possible followed by whitespace -> "|" }