当前位置:   article > 正文

使用hutool工具判断字符串是否全部是字母(包括大小写),java判断字符串是否全部是字母(包括大小写)

使用hutool工具判断字符串是否全部是字母(包括大小写),java判断字符串是否全部是字母(包括大小写)

1.导入hutool的maven依赖

     <dependency>
            <groupId>cn.hutool</groupId>
            <artifactId>hutool-all</artifactId>
            <version>5.8.16</version>
        </dependency>
  • 1
  • 2
  • 3
  • 4
  • 5

2.复制一下代码执行

import cn.hutool.core.lang.Validator;
public class Test {
    public static void main(String[] args) throws Exception{

        String word1 = "abcDEFG";
        String word2 = "12abc";
        if (Validator.isWord(word1)) {
            System.out.println(word1+"字符串全是字母");
        }else {
            System.out.println(word1+"字符串不全是字母");
        }

        if (Validator.isWord(word2)) {
            System.out.println(word2+"字符串全是字母");
        }else {
            System.out.println(word2+"字符串不全是字母");
        }
    }
}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19

在这里插入图片描述

声明:本文内容由网友自发贡献,转载请注明出处:【wpsshop】
推荐阅读
相关标签
  

闽ICP备14008679号