Java Email Validate isEmailValid(String address)

Here you can find the source of isEmailValid(String address)

Description

Checks e-mail addresses for invalid characters.

License

Open Source License

Parameter

Parameter Description
address an email address to check

Return

true if the address is valid.

Declaration

public static boolean isEmailValid(String address) 

Method Source Code


//package com.java2s;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Main {
    /**//  w  w  w  .  ja  v  a  2 s. c om
     * Checks e-mail addresses for invalid characters. If the address is invalid, false is returned.
     * <p/>
     * This might be too restrictive TODO: look at .NET version or regex.com Email address generally contain more
     * characters than this.  (flawed)
     *
     * @param address an email address to check
     * @return true if the address is valid.
     */
    public static boolean isEmailValid(String address) {
        final Pattern p = Pattern.compile("[A-Za-z0-9\\.\\@_\\-~#]+");
        final Matcher m = p.matcher(address);

        return m.matches();
    }
}

Related

  1. isEmailAddress(String input)
  2. isEmailAddressFormat(String address)
  3. isEmailAddressValid(String emailAddress)
  4. isEmailer(String email)
  5. isEmailFormatValid(String emailAddress)
  6. isEmailValid(String email)
  7. isEmailValid(String email)
  8. isEmailValid(String email)
  9. isEmailValid(String emailAddress)