Created
March 15, 2020 16:34
-
-
Save foxicode/ac892cda68440fcb779766e3590fd450 to your computer and use it in GitHub Desktop.
Kotlin String extension to analyze content
This file contains hidden or 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.containsLatinLetter: Boolean | |
| get() = matches(Regex(".*[A-Za-z].*")) | |
| val String.containsDigit: Boolean | |
| get() = matches(Regex(".*[0-9].*")) | |
| val String.isAlphanumeric: Boolean | |
| get() = matches(Regex("[A-Za-z0-9]*")) | |
| val String.hasLettersAndDigits: Boolean | |
| get() = containsLatinLetter && containsDigit | |
| val String.isIntegerNumber: Boolean | |
| get() = toIntOrNull() != null | |
| val String.toDecimalNumber: Boolean | |
| get() = toDoubleOrNull() != null |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment