Created
June 13, 2020 12:28
-
-
Save ajaypro/ff2952a03c13b6a5dba049c99a6d99ef to your computer and use it in GitHub Desktop.
sample use of substringBefore method
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
private const val EMAIL = "[email protected]" | |
fun main() { | |
val username = MY_EMAIL.substringBefore(delimiter = "@", missingDelimiterValue = "Usernmae Not Found") | |
println("Username -> $username") | |
} | |
// Output | |
Username -> ajaydeepak07 | |
Explanation: the above program returns the substring before the appearance of @ character. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment