Skip to content

Instantly share code, notes, and snippets.

@mourawaldson
Created April 28, 2012 21:33
Show Gist options
  • Save mourawaldson/2522197 to your computer and use it in GitHub Desktop.
Save mourawaldson/2522197 to your computer and use it in GitHub Desktop.
E-mail validator
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