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

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