String a="ASD1232@#";
    //System.out.println(HasDigit(a));
    
    //gettime();
    //【含有英文】true
            String regex1 = ".*[a-zA-z].*";  
            boolean result3 = a.matches(regex1);
            //【含有数字】true
            String regex2 = ".*[0-9].*";  
            boolean result4 = a.matches(regex2);
            
            String regEx = "[ _`~!@#$%^&*()+=|{}':;',\\[\\].<>/?~!@#¥%……&*()——+|{}【】‘;:”“’。,、?]|\n|\r|\t";
            Pattern p = Pattern.compile(regEx);
            boolean m = p.matcher(a).find();
            
            System.out.println("含有英文 result3:"+result3);
            System.out.println("含有数字  result4:"+result4);
            System.out.println("含有特殊字符 m:"+m);

Java  判断字符串是否含有 数字 字母 特殊字符

 

相关文章:

  • 2022-12-23
  • 2021-11-06
  • 2022-12-23
  • 2022-01-08
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-09-15
  • 2021-08-12
  • 2021-09-29
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案