java正则匹配查找是否包含大写字母

    /**
     * . 表示任一字符
     * * 等于{0,} 表示任意数量
     * .* 表示任意数量的任意字符
     * .*[A-Z]+.* 包含大写字母的字符串
     *
     * @param str
     * @return
     */
    public static boolean judgeContainsStr(String str) {
    
    
        String regex=".*[A-Z]+.*";
        Matcher m= Pattern.compile(regex).matcher(str);

        // str 能够匹配regex,返回true
        return m.matches();
    }

猜你喜欢

转载自blog.csdn.net/leinminna/article/details/113779171