isValidEmailAddress: Check the email address is Valid : Email « Network « Android






isValidEmailAddress: Check the email address is Valid

 
import java.util.regex.Matcher;
import java.util.regex.Pattern;

class Utils {
  // isValidEmailAddress: Check the email address is OK
  public static boolean isValidEmailAddress(String emailAddress) {
    String emailRegEx;
    Pattern pattern;
    // Regex for a valid email address
    emailRegEx = "^[A-Za-z0-9._%+\\-]+@[A-Za-z0-9.\\-]+\\.[A-Za-z]{2,4}$";
    // Compare the regex with the email address
    pattern = Pattern.compile(emailRegEx);
    Matcher matcher = pattern.matcher(emailAddress);
    if (!matcher.find()) {
      return false;
    }
    return true;
  }

}

   
  








Related examples in the same category

1.Email vis Intent
2.Builds a list of the recipients email addresses each on a different line
3.Is string an Email address
4.Send email
5.Launch the email intent
6.start Email Intent
7.start Html Email Intent