Created
April 28, 2012 21:33
-
-
Save mourawaldson/2522197 to your computer and use it in GitHub Desktop.
E-mail validator
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.regex.Matcher; | |
import java.util.regex.Pattern; | |
/** | |
* Valida o e-mail informado. | |
* | |
* @param str | |
* @return boolean true se o e-mail for válido; false se o e-mail for | |
* inválido. | |
*/ | |
public static boolean isValidEmail(String str) { | |
if (isNullOrEmpty(str)) | |
return false; | |
else { | |
Pattern p = Pattern.compile(".+@.+\\.[a-z]+"); | |
Matcher m = p.matcher(str); | |
boolean matchFound = m.matches(); | |
return (matchFound) ? true : false; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment