Skip to content

Instantly share code, notes, and snippets.

@foxicode
Created March 10, 2020 18:55
Show Gist options
  • Select an option

  • Save foxicode/187babb1d9795fc2a29908b2cd94a9af to your computer and use it in GitHub Desktop.

Select an option

Save foxicode/187babb1d9795fc2a29908b2cd94a9af to your computer and use it in GitHub Desktop.
Kotlin String email validator
import java.util.regex.Pattern
fun String.isEmailValid(): Boolean {
val expression = "^[\\w.-]+@([\\w\\-]+\\.)+[A-Z]{2,8}$"
val pattern = Pattern.compile(expression, Pattern.CASE_INSENSITIVE)
val matcher = pattern.matcher(this)
return matcher.matches()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment