private String asRegPattern(String string){
  StringBuffer out=new StringBuffer(string.length());
  for (int i=0, length=string.length(); i < length; i++) {
    char ch=string.charAt(i);
    if (ch == '\\') {
      out.append("\\\\");
    }
 else     if (ch == '*') {
      out.append("\\*");
    }
 else {
      out.append(ch);
    }
  }
  return out.toString();
}

private String asRegPattern ( String string ) { StringBuffer out = new StringBuffer ( string . length ( ) ) ; for ( int i = 0 , length = string . length ( ) ; i < length ; i ++ ) { char ch = string . charAt ( i ) ; if ( ch == '\\' ) { out . append ( "\\\\" ) ; } else if ( ch == '*' ) { out . append ( "\\*" ) ; } else { out . append ( ch ) ; } } return out . toString ( ) ; }
converts a non - regex string to a pattern that can be used with the regex search engine .
