Java Email Validate validEmail(String canidate)

Here you can find the source of validEmail(String canidate)

Description

Determines if the search string contains a valid Email address

License

Open Source License

Parameter

Parameter Description
canidate The string to search.

Return

true if, and only if, the entire region sequence matches this matcher's Email pattern

Declaration

public static boolean validEmail(String canidate) 

Method Source Code

//package com.java2s;
/* This file is part of Math4J.
 * Math4J is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.//from   w w  w.  j  a  v  a2 s . com
 *
 * Math4J is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with Math4J; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
 * 
 * Copyright 2005 Anthony Magee
 */

import java.util.regex.Pattern;

public class Main {
    private static final String EMAIL_RE = "\\b[a-zA-Z0-9._%-]+@[a-zA-Z0-9._%-]+\\.[a-zA-Z]{2,4}\\b";

    /**
     * Determines if the search string contains a valid Email address
     * 
     * @param canidate The string to search.
     * @return true if, and only if, the entire region sequence matches this
     *         matcher's Email pattern
     */
    public static boolean validEmail(String canidate) {
        return Pattern.matches(EMAIL_RE, canidate);
    }
}

Related

  1. validateEmail(String email)
  2. validateEmail(String email)
  3. validateEmail(String hex)
  4. validateEmail2(String field)
  5. validateEmailAddress(String address)
  6. validEmail(String email)
  7. validEmail(String p_mail)
  8. validEmailAddrWithDataExact(String str)