Java Email Validate isEmailAddress(String input)

Here you can find the source of isEmailAddress(String input)

Description

is Email Address

License

Open Source License

Declaration

public static boolean isEmailAddress(String input) 

Method Source Code

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

public class Main {
    public static boolean isEmailAddress(String input) {
        if (input == null || input.trim().length() <= 0)
            return false;

        Pattern pattern = Pattern
                .compile("^[_A-Za-z0-9-]+(\\.[_A-Za-z0-9-]+)*@[A-Za-z0-9-]+(\\.[A-Za-z0-9-]+)*((\\.[A-Za-z]{2,}){1}$)");
        // "[\S]+@[\w-]+(.[\w-]+)+"

        try {/*from  w ww .  ja  va  2 s  .c  o  m*/
            Matcher matcher = pattern.matcher(input);
            if (matcher.matches())
                return true;
            else
                return false;
        } catch (Exception e) {
            return false;
        }
    }
}

Related

  1. isEmail(String string)
  2. isEmail(String text)
  3. isEmail(String val)
  4. isEmail(String value)
  5. isEmail(String value)
  6. isEmailAddressFormat(String address)
  7. isEmailAddressValid(String emailAddress)
  8. isEmailer(String email)
  9. isEmailFormatValid(String emailAddress)