170的虚拟号码,现在越来越深受人们的喜爱,可是好的注册,并没有把他纳入进来,不过以后相信,会有更多的人的使用,而广泛设计加入,是必须的。
下面是最新的号码正则表达式:
"^((13[0-9])|(17[0])|(17[7])|(14[57])|(15[012356789])|7(17[68])|(18[0-9]))\\d{8}$"
带上我自己的工具类:
public class Phone {
public static boolean isMobileNO(String mobiles) {
Pattern p = Pattern.compile("^((13[0-9])|(17[0])|(17[7])|(14[57])|(15[012356789])|7(17[68])|(18[0-9]))\\d{8}$");
Matcher m = p.matcher(mobiles);
return m.matches();
}
/**
* 判断是否为邮箱
*
* @param email
* @return
*/
public static boolean isVaildEmail(String email) {
String emailPattern = "[a-zA-Z0-9][a-zA-Z0-9._-]{2,16}[a-zA-Z0-9]@[a-zA-Z0-9]+.[a-zA-Z0-9]+";
boolean result = Pattern.matches(emailPattern, email);
return result;
}
/**
* 用户名是否为电话号码
*
* @param name
* @return
*/
public static String getPhoneName(String name) {
return isMobileNO(name) ? name.replace(name.substring(4, 8), "***") : name;
}
}
逻辑判断:
if (regist_check_box.isChecked()) {
if (!TextUtils.isEmpty(et_regist_phone.getText().toString())) {
if (Phone.isMobileNO(et_regist_phone.getText().toString())) {
if (!TextUtils.isEmpty(et_regist_code.getText().toString())) {
if (et_regist_pwd.getText().toString().length() > 5) {
regist()
} else {
ToastUtil.showGenericToast(me, "密码长度不能小于6位")
}
} else {
ToastUtil.showGenericToast(me, "验证码不能为空")
}
} else {
ToastUtil.showGenericToast(me, "请输入正确的手机号码")
}
} else {
ToastUtil.showGenericToast(me, "手机号码不能为空")
}
} else {
ToastUtil.showGenericToast(me, "请先同意用户服务协议")
}