复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26/** * 包含大小写字母及数字且在6-16位 * 是否包含 * * @param str * @return */ public static boolean isLetterDigit(String str) { boolean isDigit = false;//定义一个boolean值,用来表示是否包含数字 boolean isLetter = false;//定义一个boolean值,用来表示是否包含字母 for (int i = 0; i < str.length(); i++) { if (Character.isDigit(str.charAt(i))) { //用char包装类中的判断数字的方法判断每一个字符 isDigit = true; } if (Character.isLetter(str.charAt(i))) { //用char包装类中的判断字母的方法判断每一个字符 isLetter = true; } } String regex = "^[a-zA-Z0-9]{6,16}$"; if ((isDigit && str.matches(regex) || (isLetter && str.matches(regex)))) { return true; } else { return false; } }
最后
以上就是冷酷美女最近收集整理的关于密码设置只能为6-16为的字母数字组合的全部内容,更多相关密码设置只能为6-16为内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复