CocoaPods trunk is moving to be read-only. Read more on the blog, there are 18 months to go.

StringInflections 0.0.6

StringInflections 0.0.6

TestsTested
LangLanguage SwiftSwift
License MIT
ReleasedLast Release Dec 2016
SwiftSwift Version 3.0
SPMSupports SPM

Maintained by Sam Williams.



  • By
  • Sam Williams

StringInflections

Case

“just in CASE”:

  • string.camelcased(): "justInCase"
  • string.camelcased(uppercaseFirst: true): "JustInCase"
  • string.underscored(): "just_in_case"
  • string.kebabCased(): "just-in-case"

There’s also a StringCase enum.

"my string".to(case: .camel)

Plural and singular

This does very simple, non-localized inflection.

  • string.pluralized()
  • string.singularized()

You can add your own regex-based rules:

Inflector.pluralizer.inflect("octopus$", as: "octopodes")
"octopus".pluralized() // "octopodes"

Inflector.singularizer.inflect("people$", as: "soylent")
"people".singularized() // "soylent"