private String replaceMetaChars(String input) {
    // escape backslash first since that character is used to escape the
    // remaining meta chars
    String result = input.replaceAll("\\\\", "\\\\\\");

    // don't escape star - it's used as the wildcard
    result = result.replaceAll(Pattern.quote("]"), "\\\\]");
    result = result.replaceAll(Pattern.quote("["), "\\\\[");
    result = result.replaceAll(Pattern.quote("^"), "\\\\^");
    result = result.replaceAll(Pattern.quote("$"), "\\\\$");
    result = result.replaceAll(Pattern.quote("."), "\\\\.");
    result = result.replaceAll(Pattern.quote("|"), "\\\\|");
    result = result.replaceAll(Pattern.quote("?"), "\\\\?");
    result = result.replaceAll(Pattern.quote("+"), "\\\\+");
    result = result.replaceAll(Pattern.quote("("), "\\\\(");
    result = result.replaceAll(Pattern.quote(")"), "\\\\)");
    result = result.replaceAll(Pattern.quote("-"), "\\\\-");
    result = result.replaceAll(Pattern.quote("{"), "\\\\{");
    result = result.replaceAll(Pattern.quote("}"), "\\\\}");
    result = result.replaceAll(Pattern.quote("#"), "\\\\#");
    return result;
  }
Some perl5 characters may occur in the log file format. Escape these characters to prevent parsing errors.

@param input
@return string
olv-core/src/main/java/pl/otros/logview/parser/log4j/Log4jPatternMultilineLogParser.java