我有一些代码:
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.apache.commons.lang.StringUtils;
private boolean validateEmail(...)
Pattern p = Pattern.compile("^((?:(?:(?:[a-zA-Z0-9][\\.\\-\\+_]?)*)[a-zA-Z0-9])+)\\@((?:(?:(?:[a-zA-Z0-9][\\.\\-_]?){0,62})[a-zA-Z0-9])+)\\.([a-zA-Z0-9]{2,6})$");
Matcher m = p.matcher(fieldValue);
boolean matches = m.matches();
if (!matches) {
// show not valid msg...
}
return matches;
}
在这种模式下是^((?:(?:(?:
什么意思?字符意味着否定(全部没有)但其他字符((?:(?:(?:
?^