Created
March 1, 2023 13:19
-
-
Save akshaykalola28/375898fcddd6be4d1b1a3aa13d615b78 to your computer and use it in GitHub Desktop.
Extension function to check the string is digit only, alphabetic only or alphanumeric only.
This file contains 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
val String.isDigitOnly: Boolean | |
get() = matches(Regex("^\\d*\$")) | |
val String.isAlphabeticOnly: Boolean | |
get() = matches(Regex("^[a-zA-Z]*\$")) | |
val String.isAlphanumericOnly: Boolean | |
get() = matches(Regex("^[a-zA-Z\\d]*\$")) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment