Here you can find the source of validateEmail(String email)
Parameter | Description |
---|---|
<code>String</code> value of email |
boolean
type value true if email is correct, false if not
public static boolean validateEmail(String email)
//package com.java2s; //License from project: Apache License import java.util.regex.Pattern; public class Main { /**//from w w w.java 2s .co m * Checks if given email is valid by matching it to regex pattern. * * @param email <code>String</code> value of email * @return <code>boolean</code> type value true if email is correct, false if not */ public static boolean validateEmail(String email) { final Pattern pattern = Pattern.compile("^[a-z0-9._%+-]+@[a-z0-9.-]+\\.[a-z]{2,4}$"); if (!pattern.matcher(email).matches()) { return false; } return true; } }