kasechange

Project Url: pearxteam/kasechange
Introduction: 🐫 - 🐍 -🍢 - 🅿 Multiplatform Kotlin library to convert strings between various case formats including Camel Case, Snake Case, Pascal Case and Kebab Case
More: Author   ReportBugs   
Tags:

License Discord Release Build Status Develop Build Status

Multiplatform Kotlin library to convert strings between various case formats

Supported Case Formats

  • SCREAMING_SNAKE_CASE
  • snake_case
  • PascalCase
  • camelCase
  • TRAIN-CASE
  • kebab-case
  • UPPER SPACE CASE
  • Title Case
  • lower space case
  • UPPER.DOT.CASE
  • dot.case

Setup

  1. Add the lib to your project's dependencies by copying one of the following lines depending on the platform:
    • Groovy (replace $kasechange_version with the version you want):
      implementation "net.pearx.kasechange:kasechange-metadata:$kasechange_version" // for Common
      // or
      implementation "net.pearx.kasechange:kasechange-jvm:$kasechange_version" // for JVM
      // or
      implementation "net.pearx.kasechange:kasechange-js:$kasechange_version" // for JS
      
    • Kotlin (replace $kasechangeVersion with the version you want):
      implementation("net.pearx.kasechange:kasechange-metadata:$kasechangeVersion") // for Common
      // or
      implementation("net.pearx.kasechange:kasechange-jvm:$kasechangeVersion") // for JVM
      // or
      implementation("net.pearx.kasechange:kasechange-js:$kasechangeVersion") // for JS
      
  2. Use the library and have fun!

    Examples:

    • Transforming string from one case to another:
      "IAmAPascalCasedString".toSnakeCase() // i_am_a_pascal_cased_string
      "IAmAPascalCasedString".toCase(CaseFormat.LOWER_UNDERSCORE)  // i_am_a_pascal_cased_string
      
  3. Transforming string to a custom case:
    "some_string".toCase(CaseFormatterConfig(CaseFormatterConfig(false, "..", wordCapitalize = true, firstWordCapitalize = true))) // Some..String
    
    • Splitting a string into words:
      "XMLExtendedParser".splitToWords() // [XML, Extended, Parser]
      
Apps
About Me
Google+: Trinea trinea
GitHub: Trinea