public boolean checkmail(String smail) {
boolean b = false;
int point = smail.indexOf("@");
String temp1 = smail.substring(0,point);
String temp2 = smail.substring(point+1);
if(temp1.indexOf(".")==-1) {
b = true; //是否@前有"."
}
if(temp2.indexOf(".")==-1) {
b = false; //是否@后有"."
}else {
if(temp2.length()-temp2.lastIndexOf()>3) {
b = false; //@后的"."后为3个字符以下(.com .cn)
}
}
return b;
}
粗略的写了一些,其他的你自己写吧
boolean b = false;
int point = smail.indexOf("@");
String temp1 = smail.substring(0,point);
String temp2 = smail.substring(point+1);
if(temp1.indexOf(".")==-1) {
b = true; //是否@前有"."
}
if(temp2.indexOf(".")==-1) {
b = false; //是否@后有"."
}else {
if(temp2.length()-temp2.lastIndexOf()>3) {
b = false; //@后的"."后为3个字符以下(.com .cn)
}
}
return b;
}
粗略的写了一些,其他的你自己写吧
~~~这里是否应该是(".")?
b = false; //@后的"."后为3个字符以下(.com .cn)
}