Skip to content

Instantly share code, notes, and snippets.

@jiraguha
Created April 9, 2020 03:11
Show Gist options
  • Save jiraguha/c538a0a8d302b602b95cf469970ff0b1 to your computer and use it in GitHub Desktop.
Save jiraguha/c538a0a8d302b602b95cf469970ff0b1 to your computer and use it in GitHub Desktop.
Convert Snake & Spinal to PascalCase in kotlin
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