Created
March 10, 2020 18:55
-
-
Save foxicode/187babb1d9795fc2a29908b2cd94a9af to your computer and use it in GitHub Desktop.
Kotlin String email validator
This file contains hidden or 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.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