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

SwiftMoji 0.5.0

SwiftMoji 0.5.0

TestsTested
LangLanguage SwiftSwift
License MIT
ReleasedLast Release Oct 2019
SPMSupports SPM

Maintained by tikidunpon.



SwiftMoji 0.5.0

  • By
  • koichi


Code Climate



Usage

To run the example project, clone the repo, and run pod install from the Example directory first.

Methods

between()

"<a>foo</a>".between("<a>", "</a>") // "foo"
"<a><a>foo</a></a>".between("<a>", "</a>") // "<a>foo</a>"
"<a>foo".between("<a>", "</a>") // nil
"Some strings } are very {weird}, dont you think?".between("{", "}") // "weird"
"<a></a>".between("<a>", "</a>") // nil
"<a>foo</a>".between("<a>", "<a>") // nil

matches()

let matches = "Swift Moji 9876".matches(regex: "^(.+)\\s(\\d{4})")

// first is the entire capture
matches.first // "Swift Moji 9876"

// individual capture groups begin from [1]
matches[1] // "Swift Moji"
matches.last // "2017"

first()

"abc".first() // "a"

second()

"abc".second() // "b"

last()

"abc".last() // "c"

hiragana()

String.hiragana() 
//ぁあぃいぅうぇえぉおかがきぎくぐけげこごさざしじすずせぜそぞただちぢっつづてでとどなにぬねのはばぱひびぴふぶぷへべぺほぼぽまみむめもゃやゅゆょよらりるれろゎわゐゑをんゔゕゖ

katakana()

String.katakana() 
//ァアィイゥウェエォオカガキギクグケゲコゴサザシジスズセゼソゾタダチヂッツヅテデトドナニヌネノハバパヒビピフブプヘベペホボポマミムメモャヤュユョヨラリルレロヮワヰヱヲンヴヵヶ

camelized()

"abc_def".camelized() // "AbcDef"

snakecased()

"UserId".snakecased() // "user_id"

trimmed() trimmedLeft() trimmedRight()

"   abcdef   ".trimmed()      // "abcdef"
"   abcdef   ".trimmedLeft()  // "abcdef   "
"   abcdef   ".trimmedRight() // "   abcdef"

uppercasedFirst()

"abc".uppercasedFirst() // "Abc"

lowercasedFirst()

"ABC".lowercasedFirst() // "aBC"

truncated()

"Returns the truncated string".truncated(length: 10)  // "Returns th..."
"Returns the truncated string".truncated(length: 10, trailing: "・・・")  // "Returns th・・・"

isCapitalized()

"Abc".isCapitalized() // "true"
"abc".isCapitalized() // "false"

isUppercased()

"ABC".isOnlyUppercased()   // "true"
"A_B_C".isOnlyUppercased() // "false"

isLowercased()

"abc".isOnlyLowercased()   // "true"
"a_b_c".isOnlyLowercased() // "false"

isUpperCamelized()

"UserId".isUpperCamelized() // "true"
"userId".isUpperCamelized() // "false"

isLowerCamelized()

"userId".isLowerCamelized() // "true"
"UserId".isLowerCamelized() // "false"

isAlphabet()

"abc".isAlphabet() // "true"
"123".isAlphabet() // "false"
"   ".isAlphabet() // "false"

isNumeric()

"-1.983388".isNumeric() // "true"
"abc".isNumeric()       // "false"

isHiragana()

"あいうえお".isHiragana() // "true"
"abc".isHiragana()      // "false"

isKatakana()

"アイウエオ".isKatakana() // "true"
"abc".isKatakana()      // "false"

Installation

SwiftMoji is available through CocoaPods. To install
it, simply add the following line to your Podfile:

pod "SwiftMoji"

Author

tikidunpon, https://twitter.com/tikidunpon

License

SwiftMoji is available under the MIT license. See the LICENSE file for more info.