Email address validation kotlin regex for android EditText

Email address validation kotlin regex for android EditText

email address validation in kotlin android


How can you do this. so, there are many way to validate email address in kotlin

1.  First Initialized your regex code for email and convert it String to Regex

   val regexPattern = "[a-zA-Z0-9._-]+@[a-z]+\\.+[a-z]+".toRegex()


2.  then add if condition on editText id  and match to Regular Expression

if(editText.matches(regexPattern)){

Toast.makeText(this, "match email address", Toast.lengthShort).show()

}


So now you are able to validate email address