java正则表达式匹配电子邮件地址20200608

package org.jimmy.studyproject.test;

import java.util.regex.Pattern;

public class Reg20200608 {

    public static Pattern pattern = Pattern.compile("[a-zA-Z]([a-zA-Z]|[.])*@[a-zA-Z]+([.][a-zA-Z]+)+");
    
    public static void main(String[] args) {
        String email = "fgf.fg@dft.com";
        System.out.println(pattern.matcher(email).matches());
        email = "fgf.fg@dft.com.cn";
        System.out.println(pattern.matcher(email).matches());
        email = "fgffg@dft.com";
        System.out.println(pattern.matcher(email).matches());
        email = "fgffg@dft.com.cn";
        System.out.println(pattern.matcher(email).matches());
        email = ".fgffg@dft.com";
        System.out.println(pattern.matcher(email).matches());
    }

}

好了

posted @ 2020-06-08 14:35  ラピスラズリ(Dawn)  阅读(385)  评论(0编辑  收藏  举报