Created
July 6, 2014 08:20
-
-
Save digvijaybhakuni/bb1634c50983b083e939 to your computer and use it in GitHub Desktop.
Validate Email with regular expression
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; | |
/** | |
* 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