Dev Research Dev Research - 7 months ago 57
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 .


Simply restrict your reg ex with the domain like below

 String EMAIL_REGEX = "^[\\w-_\\.+]*[\\w-_\\.]\\@itspl\\.com";