private String replaceMetaChars(String input){
  String result=input.replaceAll("\\\\","\\\\\\");
  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;
}

private String replaceMetaChars ( String input ) { String result = input . replaceAll ( "\\\\" , "\\\\\\" ) ; 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 .
