Dev Research Dev Research - 1 year ago 129
Java Question

how to validate particular domain with emailID in java

public static boolean isValidEmail(String emailID) {
String EMAIL_REGEX = "^[\\w-_\\.+]*[\\w-_\\.]\\@([\\w]+\\.)+[\\w]+[\\w]$";
Boolean b = emailID.matches(EMAIL_REGEX);
return b;


this is my code using this code i am able to validate emailID but i want Unique email ID validation whose domain is i.e if user Enter then it should display wrong Email ID if they Enter then it show correct please tell me how i will do this .

Answer Source

Simply restrict your reg ex with the domain like below

 String EMAIL_REGEX = "^[\\w-_\\.+]*[\\w-_\\.]\\@itspl\\.com";
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download