美文网首页Java 杂谈
判断字符串是否同时有字母和数字,且不指定以字母或数字开头

判断字符串是否同时有字母和数字,且不指定以字母或数字开头

作者: 迈小步 | 来源:发表于2018-12-26 16:46 被阅读0次

    // 判断字符串是否同时有字母和数字,且不指定以字母或数字开头
    public static boolean isLetterAndDigital(String content) {

        String regEx ="([A-Za-z][0-9]+)|([0-9]+[A-Za-z]+)";

        return Pattern.matches(regEx, content);
    }

    // 执行
    public static void main(String[] args) {

        String content ="f4";

        System.out.println(isLetterAndDigital(content));
    }

    相关文章

      网友评论

        本文标题:判断字符串是否同时有字母和数字,且不指定以字母或数字开头

        本文链接:https://www.haomeiwen.com/subject/fuzhlqtx.html