public static String escapeText(String text){
  String result=text.replace("\\E","\\\\E");
  return "\\Q" + result + "\\E";
}

public static String escapeText ( String text ) { String result = text . replace ( "\\E" , "\\\\E" ) ; return "\\Q" + result + "\\E" ; }
escapes a given string for use in a java . util . regex pattern .
