Here we will use regular expression (regex) to validate email address using Kotlin programming language.

class EmailValidator {
    companion object {
        fun isEmailValid(email: String): Boolean {
            return Patterns.EMAIL_ADDRESS.toRegex().matches(email);
        }
    }
}

or

fun String.isValidEmail(): Boolean 
  = this.isNotEmpty() && 
    Patterns.EMAIL_ADDRESS.matcher(this).matches()

Please feel free to comment if you have newer techniques as well as ask questions. And, yeah! If this post helps you please do share!

Happy coding!


Leave a Reply

Your email address will not be published. Required fields are marked *