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

 

 每天学习一点点 编程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

posted @ 2018-04-23 16:52  漫步CODE人生  阅读(1054)  评论(0编辑  收藏  举报