Java Email Validate validEmailAddrWithDataExact(String str)

Here you can find the source of validEmailAddrWithDataExact(String str)

Description

Validate the given string is exact of 'a@b.com{Mr.}{A}'.

License

Open Source License

Parameter

Parameter Description
str a parameter

Declaration

public static boolean validEmailAddrWithDataExact(String str) 

Method Source Code

//package com.java2s;

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

public class Main {
    /** Matching exact 'jack@abc.com{Jack}{Mr.}' */
    private static final String REGEX_EMAIL_WITH_DATA_EXACT = "^[\\w\\.%\\+-]+@[\\w\\.%\\+-]+\\.[A-Za-z]+(\\{[^\\}\\n]*\\})*$";
    /** Matching exact 'jack@abc.com{Jack}{Mr.}' */
    private static Pattern patternEmailWithDataExact = null;

    /**//w w w  . j ava 2 s  .  c o m
     * Validate the given string is exact of 'a@b.com{Mr.}{A}'.
     * @param str
     * @return
     */
    public static boolean validEmailAddrWithDataExact(String str) {
        if (str == null) {
            return false;
        }
        if (patternEmailWithDataExact == null) {
            patternEmailWithDataExact = Pattern.compile(REGEX_EMAIL_WITH_DATA_EXACT);
        }
        Matcher matcher = patternEmailWithDataExact.matcher(str);
        return matcher.find();
    }
}

Related

  1. validateEmail2(String field)
  2. validateEmailAddress(String address)
  3. validEmail(String canidate)
  4. validEmail(String email)
  5. validEmail(String p_mail)