int res1 = email.indexOf("@");
int res3 = email.lastIndexOf("@");
int res2 = email.indexOf(".");
int res4 = email.lastIndexOf(".");
if (res1 != -1 && res2 != -1) {
if (res1 == res3 && res2 == res4) {
if (res1 > 0 && res2 > 0 && res2 < email.length() - 1) {
if ((res2 - res1) <= 1) {// 格式不正确
System.out.println("邮箱格式不正确");
return false;
}
}
}
} else {
System.out.println("邮箱格式不正确");
return false;
}
return true;
int res3 = email.lastIndexOf("@");
int res2 = email.indexOf(".");
int res4 = email.lastIndexOf(".");
if (res1 != -1 && res2 != -1) {
if (res1 == res3 && res2 == res4) {
if (res1 > 0 && res2 > 0 && res2 < email.length() - 1) {
if ((res2 - res1) <= 1) {// 格式不正确
System.out.println("邮箱格式不正确");
return false;
}
}
}
} else {
System.out.println("邮箱格式不正确");
return false;
}
return true;