Android examples for java.util.regex:Character Pattern
make a string digestible for regexp
import android.content.Context; import android.content.res.AssetManager; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; public class Main{ /**/*from w ww . ja va2 s . co m*/ * make a string digestible for regexp. * @param s * @return string with all non alphanumeric characters replaced with .* */ public static String regexDigest(String s) { StringBuffer sb = new StringBuffer(s.length()); for (int ich = 0; ich < s.length(); ich++) { char ch = s.charAt(ich); if (Character.isLetterOrDigit(ch)) { sb.append(ch); } else { sb.append(".*"); } } return sb.toString(); } }