android密码格式验证,正则表达式
和前面的手机号,邮箱验证方式一样,正则表达式,放在utils下面
public class CheckPasswordFormat {
    private static final String TAG = "CheckPasswordFormat";
    public static boolean isPassword(String password) {
        //6-16位数字字母混合,不能全为数字,不能全为字母,首位不能为数字
        String regex = "^(?![0-9])(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]{6,16}$";
        Pattern p = Pattern.compile(regex);
        Matcher m = p.matcher(password);
        boolean isMatch = m.matches();
        Log.i(TAG, "isPassword: 是否密码正则匹配" + isMatch);
        return isMatch;
    }
}
使用
else if (!CheckPasswordFormat.isPassword(mPasswordOneContent)) {
         Toast.makeText(RegistorTwoActivity.this, "密码格式不正确:6-16位数字字母混合", Toast.LENGTH_SHORT).show();
         return;
       }