/**
* 验证手机格式
*/
public static boolean isMobileNO(String mobiles) {
String telRegex = "[1][345678]\\d{9}";// "[1]"代表第1位为数字1,"[3578]"代表第二位可以为3、5、8中的一个,"\\d{9}"代表后面是可以是0~9的数字,有9位。
if (TextUtils.isEmpty(mobiles))
return false;
else
return mobiles.matches(telRegex);
}
/**
* 验证密码格式
*/
public static boolean isPwd(String pwd) {
// 8-16位. 16位已在maxLength中显示
// 后来改成了6-16位. 已改
if (pwd.length() < 6) {
return false;
} else {
return true;
}
}
/**
* 验证身份证号码
*/
public static boolean personIdValidation(String text) {
String regx = "[0-9]{17}[Xx]";
String reg1 = "[0-9]{15}";
String regex = "[0-9]{18}";
return text.matches(regx) || text.matches(reg1) || text.matches(regex);
}
/**
* 隐藏手机号中间四位
*
* @param mobile
* @return
*/
public static String HideMobile(String mobile) {
StringBuilder sb = new StringBuilder();
if (!TextUtils.isEmpty(mobile) && mobile.length() > 6) {
for (int i = 0; i < mobile.length(); i++) {
char c = mobile.charAt(i);
if (i >= 3 && i <= 6) {
sb.append('*');
} else {
sb.append(c);
}
}
}
return sb.toString();
}
/**
* 身份证号 隐藏 年月日 从第9-16
*/
public static String HideIdentity(String number) {
StringBuilder sb = new StringBuilder();
if (!TextUtils.isEmpty(number) && number.length() > 16) {
for (int i = 0; i < number.length(); i++) {
char c = number.charAt(i);
if (i >= 8 && i <= 15) {
sb.append('*');
} else {
sb.append(c);
}
}
}
return sb.toString();
}