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()); } }
好了