import org.apache.commons.lang3.StringUtils; |
/** |
* <p>Description: [电子邮箱工具类]</p> |
* Created on 2017年10月20日 |
* @version 1.0 |
*/ |
public class EmailUtils { |
/** |
* <p>Description:[获取邮箱前缀]</p> |
* Created on 2017年10月20日 |
* |
* @param email 电子邮箱字符串 |
* @author 缪志红 |
*/ |
public static String getPrefix(String email) { |
if (StringUtils.isBlank(email)) { |
return "" ; |
} |
if (email.contains( "@" )) { |
return email.substring( 0 ,email.indexOf( "@" )); |
} else { |
return email; |
} |
} |
/** |
* <p>Description:[验证邮箱格式]</p> |
* Created on 2017年10月20日 |
* |
* @param email 电子邮箱字符串 |
* @author 缪志红 |
*/ |
public static boolean checkMail(String email) { |
return email.matches( "[a-zA-Z0-9_\\-.]+@[a-zA-Z0-9_]+(\\.[a-zA-Z0-9_]+)+" ); |
} |
} |