Last active
November 24, 2015 22:40
-
-
Save gorrotowi/b41595c368305cf174dc to your computer and use it in GitHub Desktop.
Validation mail in java
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
private final static Pattern EMAIL_ADDRESS_PATTERN = Pattern | |
.compile(/*"^(([\\w-]+\\.)+[\\w-]+|([a-zA-Z]{1}|[\\w-]{2,}))@" | |
+ "((([0-1]?[0-9]{1,2}|25[0-5]|2[0-4][0-9])\\.([0-1]?" | |
+ "[0-9]{1,2}|25[0-5]|2[0-4][0-9])\\." | |
+ "([0-1]?[0-9]{1,2}|25[0-5]|2[0-4][0-9])\\.([0-1]?" | |
+ "[0-9]{1,2}|25[0-5]|2[0-4][0-9])){1}|" | |
+ "([a-zA-Z]+[\\w-]+\\.)+[a-zA-Z]{2,4})$"*/ | |
"[A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,6}"); | |
public static boolean isMail(String email) { | |
return EMAIL_ADDRESS_PATTERN.matcher(email).matches(); | |
} | |
//Example to use | |
if(isMail(edtxMail.getText().toString())){ | |
//do something | |
} else { | |
//do something | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment