public static String reqExpEscape(String str){
  char[] arr=str.toCharArray();
  StringBuilder sb=new StringBuilder(str.length() * 2);
  for (int i=0; i < arr.length; i++) {
    sb.append('\\');
    sb.append(arr[i]);
  }
  return sb.toString();
}

public static String reqExpEscape ( String str ) { char [ ] arr = str . toCharArray ( ) ; StringBuilder sb = new StringBuilder ( str . length ( ) * 2 ) ; for ( int i = 0 ; i < arr . length ; i ++ ) { sb . append ( '\\' ) ; sb . append ( arr [ i ] ) ; } return sb . toString ( ) ; }
escape all special characters of the regular expresson language
