Validate email address : Email « Regular Expressions « Java






Validate email address


public class Main {

  public static void main(String[] args) {
    System.out.println("isValid = " + isValidEmailAddress("user@domain.com"));
  }

  static boolean isValidEmailAddress(String email) {
    String EMAIL_REGEX = "^[\\w-_\\.+]*[\\w-_\\.]\\@([\\w]+\\.)+[\\w]+[\\w]$";

    return email.matches(EMAIL_REGEX);
  }
}

 








Related examples in the same category