Java Utililty Methods Email Validate

List of utility methods to do Email Validate

Description

The list of methods to do Email Validate are organized into topic(s).

Method

booleanisEmailValid(String email)
isEmailValid: Validate email address using Java reg ex.
boolean isValid = false;
String expression = "^[\\w\\.-]+@([\\w\\-]+\\.)+[A-Z]{2,4}$";
CharSequence inputStr = email;
Pattern pattern = Pattern.compile(expression, Pattern.CASE_INSENSITIVE);
Matcher matcher = pattern.matcher(inputStr);
if (matcher.matches()) {
    isValid = true;
return isValid;
booleanisEmailValid(String emailAddress)
is Email Valid
try {
    Pattern alpha = Pattern.compile("[a-zA-Z0-9]@([\\w-]+\\.)+[\\w-]{2,4}$");
    Matcher matcher = alpha.matcher(emailAddress.trim());
    if (matcher.find())
        return true;
} catch (Exception ae) {
    return false;
return false;
booleanisLegarEmail(String email)
is Legar Email
boolean flag = false;
Pattern p = Pattern.compile("^\\w[-._\\w]*\\w@\\w[-._\\w]*\\w\\.\\w{2,6}$");
Matcher m = p.matcher(email);
flag = m.matches();
return flag;
booleanisMail(String email)
is Mail
return check(CHECK_MAIL, email);
booleanisMobilesOrEmail(String str)
is Mobiles Or Email
if (isMobileNO(str) || isEmail(str)) {
    return true;
return false;
booleanisStrEmailAddress(String str)
is Str Email Address
return PATTERN_EMAIL_ADDR.matcher(str).matches();
booleanisValidEmail(final String email)

Indicates wether a given string is a valid email address

Email format is :

  • starts with A-Za-z or '-'
  • then has any number of A-Za-z (can be zero)
  • has any number of '.'
    final String expression = "^(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|\"(?:[\\x01-\\x08\\x0b\\x0c\\x0e-\\x1f\\x21\\x23-\\x5b\\x5d-\\x7f]|\\\\[\\x01-\\x09\\x0b\\x0c\\x0e-\\x7f])*\")"
            + "@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-]*[a-z0-9]:(?:[\\x01-\\x08\\x0b\\x0c\\x0e-\\x1f\\x21-\\x5a\\x53-\\x7f]|\\\\[\\x01-\\x09\\x0b\\x0c\\x0e-\\x7f])+)\\])$";
    final Pattern pattern = Pattern.compile(expression);
    final Matcher matcher = pattern.matcher(email);
    return matcher.matches();
    
  • booleanisValidEmail(final String email)
    Validate the format of a user entered email
    final Matcher matcher = pattern.matcher(email);
    return matcher.matches();
    
    booleanisValidEmail(String email)
    Test if a given email string is a valid E-mail address.
    return email != null && EMAIL_PATTERN.matcher(email).matches();
    
    booleanisValidEmail(String email)
    is Valid Email
    boolean err = false;
    String regex = "^[_a-z0-9-]+(.[_a-z0-9-]+)*@(?:\\w+\\.)+\\w+$";
    Pattern p = Pattern.compile(regex);
    Matcher m = p.matcher(email);
    if (m.matches()) {
        err = true;
    return err;
    ...