Here you can find the source of validateEmail(String email)
Parameter | Description |
---|---|
a parameter |
public static boolean validateEmail(String email)
//package com.java2s; //License from project: Open Source License import java.util.regex.Pattern; public class Main { /**/*from w ww .j a v a 2 s. c om*/ * Validates an email address. * * Taken from: * http://www.mkyong.com/regular-expressions/how-to-validate-email-address-with-regular-expression/ * * @param email * @return True if valid, false otherwise. */ public static boolean validateEmail(String email) { if (email != null) { Pattern pattern = Pattern.compile( "^[_A-Za-z0-9-\\+]+(\\.[_A-Za-z0-9-]+)*@[A-Za-z0-9-]+(\\.[A-Za-z0-9]+)*(\\.[A-Za-z]{2,})$"); return pattern.matcher(email).matches(); } else { return false; } } }