This library seeks to add common string manipulation functions that are needed in both mobile and server-side development, but are missing in Swift's Foundation library.
The full documentation can be found at http://www.sabintsev.com/Guitar/.
- Release Stage: Alpha (until v0.1.0)
- Development Status: Active Development (as of March 1, 2017)
- Contributions are highly encouraged.
- Boolean Functions (
isAlpha
,isNumeric
,isUppercase
, etc.) - Case Functions (
camelCased
,pascalCased
,kebabCased
, etc.) - Character Functions (
first
,length
,reverse
, etc.) - Latinization Functions
- HTML Manipulation Functions
- Padding Functions (
padLeft
,padRight
,pad
) - Regular Expressions / Regex (Pure Swift Implementation)
- Trimming Functions (
trimLeft
,trimRight
,prefixed
, etc.)
- Inline Function Documentation
- Jazzy Function Documentation (http://sabintsev.com/Guitar)
- README Function Documentation
- Carthage Support
- CocoaPods Support
- Swift Package Manager
- Continuous Integration with Buddy Build
- SwiftLint Integration
- Unit Tests
pod 'Guitar'
github "ArtSabintsev/Guitar"
.Package(url: "https://github.com/ArtSabintsev/Guitar.git")
let string = "HelloWorld"
string.isAlpha() // True
let string = "Hell0World"
string.isAlpha() // False
let string = "HelloWorld"
string.isAlphanumeric() // True
let string = "Hell0World"
string.isAlphanumeric() // True
let string = "Hell0 World"
string.isAlphanumeric() // False
let string = "Hello World"
string.isCapitalized() // True
let string = "hello World"
string.isCapitalized() // False
let string = "Hello-World"
string.isCapitalized() // True
let string = "hello World"
string.isDecapitalized() // True
let string = "Hello World"
string.isDecapitalized() // False
let string = "hello-World"
string.isDecapitalized() // True
// Note, Swift treats non-alphabetical characters as Uppercased.
let string = "helloworld"
string.isLowercased() // True
let string = "hello world"
string.isLowercased() // False
let string = "hello-world"
string.isLowercased() // False
let string = "73110"
string.isNumeric() // True
let string = "73110 1337"
string.isNumeric() // False
let string = "73110World"
string.isNumeric() // False
// Note, Swift treats non-alphabetical characters as Uppercased.
let string = "HELLOWORLD"
string.isUpppercased() // True
let string = "HELLO WORLD"
string.isUpppercased() // True
let string = "HELLO-W0RLD"
string.isUpppercased() // True
let string = "HeLLoW0RLD"
string.isUpppercased() // False
let string = "Hello World"
string.camelCased() // "helloWorld"
let string = "hello_world"
string.camelCased() // "helloWorld"
// Implementation is currently broken.
let string = "Hello World"
string.kebabCased() // "-Hello-World-"
let string = "hello_world"
string.kebabCased() // "-hello-world-"
let string = "Hello World"
string.pascalCased() // "HelloWorld"
let string = "hello_world"
string.pascalCased() // "HelloWorld"
let string = "Hello World"
string.slugCased() // "Hello-World"
let string = "Hello World"
string.snakeCased() // "Hello_World"
let string = "Hello World"
string.swapCased() // "hELLO wORLD"
let string = "Hello World"
string.first() // "H"
let string = "Hello World"
string.last() // "d"
let string = "Hello World"
string.length() // "11"
let string = "Hello World"
string.reversed() // "dlroW olleH"
let string = "Hello World" // 11 Characters
string.padLeft(length: 15) // " Hello World"
let string = "Hello World" // 11 Characters
string.padLeft(length: 15, withToken: "*") // "****Hello World"
let string = "Hello World" // 11 Characters
string.padLeft(length: 5) // Returns the original string, "Hello World"
let string = "Hello World" // 11 Characters
string.padRight(length: 15) // "Hello World "
let string = "Hello World" // 11 Characters
string.padRight(length: 15, withToken: "*") // "Hello World****"
let string = "Hello World" // 11 Characters
string.padRight(length: 5) // Returns the original string, "Hello World"
let string = "Hello World" // 11 Characters
string.pad(length: 15) // " Hello World "
let string = "Hello World" // 11 Characters
string.pad(length: 5) // Returns the original string, "Hello World"
let string = "Hello World" // 11 Characters
string.pad(length: 15, withToken: "*") // "**Hello World**"
/* Note: If the difference between the final length
and number of characters in the original string is odd,
the string is padded extra on the right side.
*/
let string = "Hello World" // 11 Characters
string.pad(length: 16) // " Hello World "
let string = "Hello World" // 11 Characters
string.pad(length: 16) // "**Hello World***"
let string = "Hello World"
string.prefixed(length: 7) // "Hello W"
let string = "Hello World"
string.suffixed(length: 7) // "o World"
let string = "Hello World"
string.trimLeft(length: 7) // "orld"
let string = "Hello World"
string.trimRight(length: 7) // "Hell"
let string = "Hello World"
string.truncated(length: 7) // "Hell..." (Appends an ellipsis, ..., to the end of the string.)
This project was inspired by Voca.