Here you can find the source of isValidEmail(String email)
Parameter | Description |
---|---|
E-mail address to validate. |
public static boolean isValidEmail(String email)
//package com.java2s; //License from project: Open Source License import java.util.regex.Pattern; public class Main { /**/*from w ww . j a va 2 s . c o m*/ * Regular expression to validate E-mail string. */ private static final Pattern EMAIL_PATTERN = Pattern .compile("^[_A-Za-z0-9-+]+(\\.[_A-Za-z0-9-]+)*@[A-Za-z0-9-]+(\\.[A-Za-z0-9]+)*(\\.[A-Za-z]{2,})$"); /** * Test if a given <i>email</i> string is a valid E-mail address. The matching is based on RFC-5322 with some * extensions. * * @param email E-mail address to validate. * @return {@code true} if provided string is a valid E-mail address, {@code false} if not. */ public static boolean isValidEmail(String email) { return email != null && EMAIL_PATTERN.matcher(email).matches(); } }