Android examples for java.util.regex:Digit Pattern
Is string only having digit and letter by regular expression
import android.text.TextUtils; import java.util.regex.Matcher; import java.util.regex.Pattern; public class Main{ public static boolean filter(String str) { String newStr = trim(str); String regEx = "[0-9A-Za-z_]*"; Pattern p = Pattern.compile(regEx); Matcher m = p.matcher(newStr); if (m.matches()) { return true; }/*from w w w .ja v a 2 s . com*/ return false; } }