输入:
public class JudgeEmail {输出:
public static void main(String[] args) {
//定义要匹配的Email地址的正则表达式
String regex="\\w+@\\w+(\\.\\w+)+";
String str1="aaa@";
String str2="123456789@qq.com";
String str3="111@aabbcc.com.cn";
String str4="mnimh@hhhh.etc.cn";
if (str1.matches(regex))
System.out.println("1");
if (str2.matches(regex))
System.out.println("2");
if (str3.matches(regex))
System.out.println("3");
if (str4.matches(regex))
System.out.println("4");
}
}