Skip to content

Instantly share code, notes, and snippets.

@thekarthiksankar
Created July 17, 2021 05:25
Show Gist options
  • Save thekarthiksankar/7b81142d899eb3ab446f34ba6099150c to your computer and use it in GitHub Desktop.
Save thekarthiksankar/7b81142d899eb3ab446f34ba6099150c to your computer and use it in GitHub Desktop.
Email regex for android
import java.util.regex.Pattern
fun isEmailValid(email: String): Boolean {
return 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})$"
).matcher(email).matches()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment