Here you can find the source of isEmailValid(String address)
Parameter | Description |
---|---|
address | an email address to check |
public static boolean isEmailValid(String address)
//package com.java2s; import java.util.regex.Matcher; import java.util.regex.Pattern; public class Main { /**// w w w . ja v a 2 s. c om * Checks e-mail addresses for invalid characters. If the address is invalid, false is returned. * <p/> * This might be too restrictive TODO: look at .NET version or regex.com Email address generally contain more * characters than this. (flawed) * * @param address an email address to check * @return true if the address is valid. */ public static boolean isEmailValid(String address) { final Pattern p = Pattern.compile("[A-Za-z0-9\\.\\@_\\-~#]+"); final Matcher m = p.matcher(address); return m.matches(); } }