Skip to content

Instantly share code, notes, and snippets.

@Skyyo
Last active August 8, 2020 16:47
Show Gist options
  • Save Skyyo/4d151de091d319018b57a139109f9673 to your computer and use it in GitHub Desktop.
Save Skyyo/4d151de091d319018b57a139109f9673 to your computer and use it in GitHub Desktop.
#extensions
package com.skyyo.ext
inline val CharSequence?.isEmail: Boolean get() = isMatch(REGEX_EMAIL)
fun CharSequence?.isMatch(regex: String): Boolean =
!this.isNullOrEmpty() && Regex(regex).matches(this)
const val REGEX_EMAIL = "^\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*$"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment