Here you can find the source of validateEmail(String email)
Parameter | Description |
---|---|
The email. |
public static boolean validateEmail(String email)
//package com.java2s; /*/*w w w . ja v a2s . c o m*/ * ------------------------------------------------------------------------------ * Hermes FTP Server * Copyright (c) 2005-2014 Lars Behnke * ------------------------------------------------------------------------------ * * This file is part of Hermes FTP Server. * * Hermes FTP Server 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. * * Hermes FTP Server 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 Hermes FTP Server; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * ------------------------------------------------------------------------------ */ import java.util.regex.Pattern; public class Main { /** * Validates the syntax of the passed email. * * @param email The email. * @return True, if syntax ok. */ public static boolean validateEmail(String email) { String patternStr = "^[a-zA-Z][\\w\\.-]*[a-zA-Z0-9]@" + "[a-zA-Z0-9][\\w\\.-]*[a-zA-Z0-9]\\.[a-zA-Z][a-zA-Z\\.]*[a-zA-Z]$"; return Pattern.matches(patternStr, email); } }