- public class EmailMatch {
- public static void main(String[] args) {
- System.out.println("result = " + emailValidator("adam6790163.cn"));
- }
- public static boolean emailValidator(String email)
- {
- Pattern pattern;
- Matcher matcher;
- final String EMAIL_PATTERN = "^[_A-Za-z0-9-]+@[A-Za-z0-9]+(\\.[A-Za-z]{2,})$";
- pattern = Pattern.compile(EMAIL_PATTERN);
- matcher = pattern.matcher(email);
- return matcher.matches();
- }
- }
复制代码
楼主 你复杂化 了 用这个正则表达式就OK了 ^[_A-Za-z0-9-]+@[A-Za-z0-9]+([url=file://\\.[A-Za-z]{2,})$]\\.[A-Za-z]{2,})$[/url]
|