Popularity
3.4
Stable
Activity
5.9
Declining
39
1
4

Programming language: Kotlin
Tags: Misc    
Latest version: v1.3.0

kasechange alternatives and similar libraries

Based on the "Misc" category

Do you think we are missing an alternative of kasechange or a related project?

Add another 'Misc' Library

README

KaseChange Maven Central Awesome Kotlin Badge

License Discord Test & Deploy | develop Test & Deploy | master

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
  • custom one :)

Setup

  1. Add the lib to your project's dependencies:
  • Groovy (replace $kasechange_version with the version you want):

    // universal dependency for Gradle 5.3 and above
    // in case of multiplatform project, just specify the dependency for commonMain/commonTest source set
    implementation "net.pearx.kasechange:kasechange:$kasechange_version" 
    
    // for Gradle versions below 5.3:
    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
    // or
    implementation "net.pearx.kasechange:kasechange-android:$kasechange_version" // for Android
    // or
    implementation "net.pearx.kasechange:kasechange-PLATFORM_YOU_WANT:$kasechange_version" // for Native
    
  • Kotlin (replace $kasechangeVersion with the version you want):

    // universal dependency for Gradle 5.3 and above
    // in case of multiplatform project, just specify the dependency for commonMain/commonTest source set
    implementation("net.pearx.kasechange:kasechange:$kasechangeVersion") 
    
    // for Gradle versions below 5.3:
    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
    // or
    implementation("net.pearx.kasechange:kasechange-android:$kasechangeVersion") // for Android
    // or
    implementation("net.pearx.kasechange:kasechange-PLATFORM_YOU_WAN:$kasechangeVersion") // for Native
    
  1. Use the library and have fun! # Examples:
    • Transforming string from any case to specific one: kotlin "IAmAPascalCasedString123".toSnakeCase() // i_am_a_pascal_cased_string_123 "IAmAPascalCasedString123".toCase(CaseFormat.LOWER_UNDERSCORE) // i_am_a_pascal_cased_string_123 "IAmAPascalCasedString123".toCase(to = CaseFormat.LOWER_UNDERSCORE, from = universalWordSplitter()) // i_am_a_pascal_cased_string_123 "IAmAPascalCasedString123".toSnakeCase(universalWordSplitter()) // i_am_a_pascal_cased_string_123 "IAmAPascalCasedString123".toCase(to = CaseFormat.LOWER_UNDERSCORE, from = universalWordSplitter(treatDigitsAsUppercase = false)) // i_am_a_pascal_cased_string123 "IAmAPascalCasedString123".toSnakeCase(universalWordSplitter(treatDigitsAsUppercase = false)) // i_am_a_pascal_cased_string123
    • Transforming string from one case to another: kotlin "123e4567-e89b-12d3-a456-426655440000".toSnakeCase(CaseFormat.LOWER_HYPHEN) // 123e4567_e89b_12d3_a456_426655440000 "123e4567-e89b-12d3-a456-426655440000".toCase(to = CaseFormat.LOWER_UNDERSCORE, from = CaseFormat.LOWER_HYPHEN) // 123e4567_e89b_12d3_a456_426655440000
  2. Transforming string to a custom case: kotlin "some_string".toCase(CaseFormatterConfig(false, "..", wordCapitalize = true, firstWordCapitalize = true)) // Some..String
    • Splitting a string in any case into words: kotlin "XMLExtendedParser".splitToWords() // [XML, Extended, Parser] "XMLExtendedParser2".splitToWords(universalWordSplitter(treatDigitsAsUppercase = true)) // [XML, Extended, Parser, 2] "XMLExtendedParser2".splitToWords(universalWordSplitter(treatDigitsAsUppercase = false)) // [XML, Extended, Parser2]
    • Splitting a string in specific case into words: kotlin "s0meth1ng_in_snake_case".splitToWords(CaseFormat.LOWER_UNDERSCORE) // [s0meth1ng, in, snake, case]


*Note that all licence references and agreements mentioned in the kasechange README section above are relevant to that project's source code only.