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

StringcleanUpEmailAddress(CharSequence address)
Strip off some spurious characters that make it harder to dedup
return ADDRESS_CLEANUP.matcher(address).replaceAll("");
booleancontainsEmail(String chunk)
If the chunk looks like it contains an email
if (chunk == null) {
    return false;
if (EMAIL.matcher(chunk).find()) {
    return true;
return false;
StringextractEmail(String string, StringBuffer sb)
extract Email
Matcher emailMatcher = EMAIL.matcher(string);
String email = "";
while (emailMatcher.find()) {
    emailMatcher.appendReplacement(sb, "");
    email = emailMatcher.group(1);
emailMatcher.appendTail(sb);
return email;
...
SetextractEmailAddresses(final String text)
This method analyses a text for email addresses and returns a set of those found.
final Set<String> addresses = new HashSet<String>();
final Pattern p = Pattern.compile(EMAIL_REG_EXP);
final Matcher m = p.matcher(text);
while (m.find()) {
    addresses.add(m.group(0));
return addresses;
Stringformat(String emails)
Parses the parameter for valid email addresses
if (emails == null)
    return "";
StringBuilder target = new StringBuilder();
Pattern p = Pattern.compile("[,\\s|;]+");
String[] result = p.split(emails);
for (int i = 0; i < result.length; i++) {
    if (!isEmailValid(result[i]))
        continue;
...
StringgetEmail(String author)
Get email address of the author.
Matcher emailMatcher = EMAIL_PATTERN.matcher(author);
String email = author;
if (emailMatcher.find()) {
    email = emailMatcher.group(1).trim();
return email;
StringgetEmailAddressFromDN(String dn)
get Email Address From DN
Pattern emailPattern = Pattern.compile("Email=([^/]*)");
Matcher m = emailPattern.matcher(dn);
if (m.find()) {
    return m.group(1);
return null;
StringgetEmailListStr(String tempStr)
get Email List Str
List<String> list = new ArrayList<String>();
String regex = "[^a-zA-Z-]To: (.+)";
Pattern ptn = Pattern.compile(regex);
Matcher mc = null;
mc = ptn.matcher(tempStr);
String temp = null;
System.out.println("\n\n------------------------------------");
while (mc.find()) {
...
ListgetEmails(String str)
get Emails
Matcher matcher = EMALE_PATTERN.matcher(str);
List<String> list = null;
String email = null;
while (matcher.find()) {
    if (list == null) {
        list = new ArrayList<String>();
    email = matcher.group();
...
StringgetFirstEmailAddr(String s)
Returns the first email address found in the given string or null if not found.
if (s == null) {
    return null;
if (patternEmail == null) {
    patternEmail = Pattern.compile(REGEX_EMAIL);
Matcher matcher = patternEmail.matcher(s);
if (matcher.find()) {
...