Java正则表达式的最简单应用

        String emailRegex = "^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$";
        Pattern pat = Pattern.compile(emailRegex);
        Boolean matchFlag = pat.matcher("aabcc-gedt@163.com").find();
        if (matchFlag)
        {
            System.out.println("match");
        }
        else
        {
            System.out.println("do not match");
        }
        
        //简写
        if (Pattern.compile(emailRegex).matcher("aabcc-gedt@163.com").find())
        {
            System.out.println("match");
        }
        else
        {
            System.out.println("do not match");
        }
原文地址:https://www.cnblogs.com/aaronhoo/p/5239917.html