public static boolean isEmail ( String email){
String emailChar = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_.";
String domainChar = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-";
String domainExt = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
String[] a,b;
String aleft = "",aright = "";
int indexPosition = -1;
indexPosition = email.indexOf("@");
if (indexPosition==-1) return false;
if (indexPosition!=email.lastIndexOf("@")) return false;
if (indexPosition==email.length()-1) return false;
a = StringToStringArray(email,"@");
aleft = a[0];
if (!isInString(aleft,emailChar)) return false;
aright = a[1];
if (aright.indexOf(".")==-1) return false;
if (aright.indexOf(".")==0) return false;
if (aright.lastIndexOf(".")==aright.length()-1) return false;
b = StringToStringArray(aright,".");
for (int i=0;i<b.length;i++){
if (!isInString(b[i],domainChar)) return false;
if (i==b.length-1){
if (!isInString(b[i],domainExt)) return false;
}
}
return true;
}
本文地址:http://com.8s8s.com/it/it9949.htm