Here you can find the source of validEmail(String canidate)
Parameter | Description |
---|---|
canidate | The string to search. |
public static boolean validEmail(String canidate)
//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); } }