Commit 8e3a203c authored by 董建华's avatar 董建华

增加校验

parent 979e976e
......@@ -55,7 +55,6 @@ public class AddressFilter {
}
/**
* 是否包含特殊字符
*
......@@ -95,38 +94,42 @@ public class AddressFilter {
//替换email
public static String getEmail(String phone,String email) {
public static String getEmail(String phone, String email) {
if (null != email) {
//去掉所有的空白
if(null != email){
email = email.replaceAll("\\s","");
email = email.replaceAll("\\s", "");
//替换首尾中文
Matcher matcher = CHINA_PATTERN.matcher(email);
if(matcher.find()){
if (matcher.find()) {
email = matcher.replaceAll("");
}
}
if(isEmail(email)){
//去掉空白和首尾中文后在判断是否合法
if (isEmail(email)) {
return email;
}
if( null == phone){
//如果还不合法那么用手机号替换
if (null == phone) {
return null;
}
String phonePre = phone;
if(phone.length()>3){
if (phone.length() > 3) {
phonePre = phone.substring(0, 3);
}
Set<Map.Entry<List<String>, String>> entries = OPERATO_MAP.entrySet();
for (Map.Entry<List<String>, String> entry : entries) {
boolean contains = entry.getKey().contains(phonePre);
if(contains){
if (contains) {
return phone.concat(entry.getValue());
}
}
return phone.concat(UNICOM_SUFFIX);
}
//校验是否是邮箱
public static boolean isEmail(String email){
if(null == email){
public static boolean isEmail(String email) {
if (null == email) {
return false;
}
Matcher matcher = EMAIL_PATTERN.matcher(email);
......@@ -140,5 +143,4 @@ public class AddressFilter {
private String target;
private String replaceMent;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment