Created
April 9, 2020 03:11
-
-
Save jiraguha/c538a0a8d302b602b95cf469970ff0b1 to your computer and use it in GitHub Desktop.
Convert Snake & Spinal to PascalCase in kotlin
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 str = "my-name_is"; | |
val result = str.replace("(-.)|(_.)".toRegex()) { | |
it.value[1].toString() | |
.toUpperCase() | |
}.capitalize() | |
println(result) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment