How can I restrict only numerics in the Email address. I tried below and it didn't work. My email should accept Alpha-numerics, dot, hyphen and underscore followed by "@AnyDomain.com". But it should not accept only numerics like "[email protected]"
Pattern regexPattern = Pattern.compile("^[(a-zA-Z0-9-\\_\\.!\\D)]+@[(a-zA-Z)]+\\.[(a-zA-Z)]{2,3}$");
Matcher regmatcher = regexPattern.matcher(email);
- [email protected] -> Valid
- [email protected] -> Invalid