https://github.com/digipolitan/string-case-swift
https://github.com/digipolitan/string-case-swift
camelcase snakecase string-casing swift
Last synced: 3 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/digipolitan/string-case-swift
- Owner: Digipolitan
- License: bsd-3-clause
- Created: 2017-06-26T09:47:52.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2019-01-06T22:13:02.000Z (over 6 years ago)
- Last Synced: 2025-01-17T00:20:12.521Z (4 months ago)
- Topics: camelcase, snakecase, string-casing, swift
- Language: Swift
- Size: 12.7 KB
- Stars: 1
- Watchers: 3
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
StringCase
=================================[](https://developer.apple.com/swift/)
[](https://swift.org/package-manager/)
[](http://twitter.com/Digipolitan)String extension to write camelCase string and snakeCase string
## Installation
### SPM
To install StringCase with SwiftPackageManager, add the following lines to your `Package.swift`.
```swift
let package = Package(
name: "XXX",
products: [
.library(
name: "XXX",
targets: ["XXX"]),
],
dependencies: [
.package(url: "https://github.com/Digipolitan/string-case-swift.git", from: "1.0.0")
],
targets: [
.target(
name: "XXX",
dependencies: ["StringCase"])
]
)
```## The Basics
- CamelCase
Transform the current string to a camel case string as follow :
```swift
let res = "i love swift".camelCased()
print("\(res)") // Will print iLoveSwift
``````swift
let res = " i love swift ".camelCased(.capitalized)
print("\(res)") // Will print ILoveSwift
```- SnakeCase
Transform the current string to a snake case string as follow :
```swift
let res = "i love swift".snakeCased()
print("\(res)") // Will print i_love_swift
``````swift
let res = "i_LOVE SWIFT".snakeCased()
print("\(res)") // Will print i_love_swift
``````swift
let res = " iLove Swift ".snakeCased(.upper)
print("\(res)") // Will print I_LOVE_SWIFT
```## Contributing
See [CONTRIBUTING.md](CONTRIBUTING.md) for more details!
This project adheres to the [Contributor Covenant Code of Conduct](CODE_OF_CONDUCT.md).
By participating, you are expected to uphold this code. Please report
unacceptable behavior to [[email protected]](mailto:[email protected]).## License
StringCase is licensed under the [BSD 3-Clause license](LICENSE).