Kotlin: String Conversion – First Letter to Lower/Upper, Camel Case and Snake Case


I wrote the code to convert string in Kotlin. This time I tried the following 4 patterns.

  • Make first letter lower
  • Make first letter upper
  • Convert snake case string to camel case
  • Convert camel case string to snake case

I published in GitHub. And you can use it in your project when you write the dependencies into your build.gradle.

Code

Make first letter lower

We can use regular expression also.

Make first letter upper

Convert snake case string to camel case

Convert camel case string to snake case