All Downloads are FREE. Search and download functionalities are using the official Maven repository.

commonMain.org.dbtools.kmp.commons.text.EmailUtil.kt Maven / Gradle / Ivy

The newest version!
package org.dbtools.kmp.commons.text

object EmailUtil {
    fun isValidEmailAddress(email: String): Boolean = EMAIL_ADDRESS.matches(email)
    fun getUsername(email: String): String? = "^[^@]*".toRegex().find(email)?.value
    fun getDomain(email: String): String? = "@(.*$)".toRegex().find(email)?.groupValues?.get(1)

    private val EMAIL_ADDRESS: Regex = """[a-zA-Z0-9+._%\-]{1,256}@[a-zA-Z0-9][a-zA-Z0-9\-]{0,64}(\.[a-zA-Z0-9][a-zA-Z0-9\-]{0,25})+""".toRegex()
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy