Validate an Email using Regex in Java

Here's a regular expression and method for validating emails in Java. This method returns true when an email is valid else returns false:


public static final String REGEX_EMAIL =
            "^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-][email protected]((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\])|(([a-zA-Z\\-0-9]+\\.)+[a-zA-Z]{2,}))$";

public static final boolean validateEmail(String email) {
    Pattern p = Pattern.compile(PatternConstants.REGEX_EMAIL);
    Matcher m = p.matcher(email);
    return m.matches();
}