zoukankan      html  css  js  c++  java
  • java判断字符必须包含大写字母、小写字母、数字、特殊符号且10位及以上

    运用正则判断密码必须包含大写字母、小写字母、数字、特殊符号且10及以上

     1 package com.test.tokenserver.util;
     2 
     3 
     4 public class test {
     5 //    public static final String PW_PATTERN = "^(?![A-Za-z0-9]+$)(?![a-z0-9\W]+$)(?![A-Za-z\W]+$)(?![A-Z0-9\W]+$)[a-zA-Z0-9\W]{10,}$";
     6 
     7     public static void main(String[] args) {
     8         System.out.println(checkPswd(null));
     9         System.out.println(checkPswd(""));
    10         System.out.println(checkPswd("123456789987"));
    11         System.out.println(checkPswd("asdfghjklb"));
    12         System.out.println(checkPswd("ASDFGHJKLB"));
    13         System.out.println(checkPswd("<>?:;'/.,;;,,,...@#$^^%^&*("));
    14         System.out.println(checkPswd("AaaaaBbbbb"));
    15         System.out.println(checkPswd("111111Aaaa"));
    16         System.out.println(checkPswd("11111.Aaa"));
    17         System.out.println(checkPswd("11111.Aaaa"));
    18 
    19     }
    20 
    21     /***
    22      *
    23      * @author Y.C
    24      * @date 2021-10-14 13:33:28
    25      * java判断字符是否包含大写字母、小写字母、数字、特殊符号
    26      * (不是字母,数字,下划线,汉字的字符)的10位及以上
    27      *
    28      */
    29     public static final String PW_PATTERN = "^(?![A-Za-z0-9]+$)(?![a-z0-9\W]+$)(?![A-Za-z\W]+$)(?![A-Z0-9\W]+$)[a-zA-Z0-9\W]{10,}$";
    30     public static final boolean checkPswd(String pswd){
    31         boolean falg = false;
    32         try {
    33             if (null==pswd&&pswd.isEmpty()&&pswd.length()>9){
    34                 return  falg;
    35             }
    36             //不全是特殊符号 不全是数字 不全是字母 不全是大写 不全是小写
    37             if (pswd.matches(PW_PATTERN)){
    38                 falg = true;
    39             }
    40 
    41         } catch (Exception e) {
    42             falg = false;
    43         }
    44         return  falg;
    45     }
    46  
    47 }
  • 相关阅读:
    求1+2+…+n, 要求不能使用乘除法、for、while、if、else、switch、case等关键字以及条件判断语句(A?B:C)。
    3,具体例子
    二十八.享元模式
    三十一.设计模式总结创建型模式
    1,学习LinQ
    软件公司需要具备什么能力的大学毕业生?
    二十九.解释器模式
    三十三.设计模式总结行为型模式
    三十二.设计模式总结结构型模式
    三十.访问者模式
  • 原文地址:https://www.cnblogs.com/yangchengdebokeyuan/p/15406523.html
Copyright © 2011-2022 走看看