Skip to content

Instantly share code, notes, and snippets.

@digvijaybhakuni
Created July 6, 2014 08:20
Show Gist options
  • Save digvijaybhakuni/bb1634c50983b083e939 to your computer and use it in GitHub Desktop.
Save digvijaybhakuni/bb1634c50983b083e939 to your computer and use it in GitHub Desktop.
Validate Email with regular expression
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* Give true is all condition matches, otherwise false.
* @param String
* @return boolean
*/
private boolean validateEmail(String email){
String rEmail = "^[_A-Za-z0-9-\\+]+(\\.[_A-Za-z0-9-]+)*@[A-Za-z0-9-]+(\\.[A-Za-z0-9]+)*(\\.[A-Za-z]{2,})$";
Pattern pattern = Pattern.compile(rEmail);
Matcher matcher = pattern.matcher(password);
return matcher.matches();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment