判断密码是纯数字或是纯字母

it2022-05-23  159

 

 每天学习一点点 编程PDF电子书、视频教程免费下载:http://www.shitanlife.com/code

List<String> typeList = new ArrayList<String>(); typeList.add("1"); typeList.add("2"); typeList.add("3"); String decryptPassword = "adfsdfsdfdf";

if(typeList.contains("1")) { if (decryptPassword.length() < 6) { System.out.println("1111111111111"); return "1111111111failed"; } } // 纯数字 if(typeList.contains("2")) { Pattern pattern = Pattern.compile("[0-9]{1,}"); Matcher matcher = pattern.matcher((CharSequence)decryptPassword); boolean result=matcher.matches(); if (result) { System.out.println("22222222222222"); return "22222222222failed"; } } // 纯字母 if(typeList.contains("3")) { Pattern pattern = Pattern.compile("[a-zA-Z]{1,}"); Matcher matcher = pattern.matcher((CharSequence)decryptPassword); boolean result=matcher.matches(); if (result) { System.out.println("3333333333333"); return "333333333333failed"; } }

 

每天学习一点点 编程PDF电子书、视频教程免费下载:http://www.shitanlife.com/code

转载于:https://www.cnblogs.com/scode2/p/8920176.html


最新回复(0)