Latest 0.0.4
Homepage https://github.com/tnantoka/StringFilter
License MIT
Platforms ios 9.1, requires ARC
Authors

Build Status codecov.io Carthage compatible

A swifty text converter.

Live Example on Server Side Swift

https://stringfilter.herokuapp.com/

Installtion

Swift Package Manager (SPM)

“`:swift
.Package(url: "https://github.com/tnantoka/StringFilter.git", majorVersion: 0, minor: 0),


### CocoaPods

```:ruby
pod 'StringFilter'

Carthage

github "tnantoka/StringFilter"

Usage

import StringFilter

let message = "ifmmp-!xpsme"
let filters = [
    StringFilter.shift(-1),
    .capitalize,
    .replace("$", "!")
]
print(message.str_filter(filters)) // "Hello, World!"

Built-in filters

Case Source Result
.capitalize test Test
.lowercase TEST test
.uppercase test TEST
.shift(1) test uftu
.repeat(2)) test testtest
.replace("t", "T") test TesT
.japanese(.hiragana, .katakana) あいうえお アイウエオ
.japanese(.katakana, .hiragana) アイウエオ あいうえお
.japanese(.full(.alphabet), .half(.alphabet)) ABCDE ABCDE
.japanese(.half(.alphabet), .full(.alphabet)) ABCDE ABCDE
.japanese(.full(.number), .half(.number)) 0123456789 0123456789
.japanese(.half(.number), .full(.number)) 0123456789 0123456789
.japanese(.full(.katakana), .half(.katakana)) アイウエオ アイウエオ
.japanese(.half(.katakana), .full(.katakana)) アイウエオ アイウエオ

Custom filter

struct ExclaimFilter: StringFilterType {
    func transform(_ string: String) -> String {
        return string + "!"
    }
}

let customFilter = ExclaimFilter() * 3 * StringFilter.uppercase
print("Hello".str_filter(customFilter)) // "HELLO!!!"

TODO

  • [ ] Chinese numeral

Acknowledgements

Latest podspec

{
    "name": "StringFilter",
    "version": "0.0.4",
    "summary": "A swifty text converter.",
    "homepage": "https://github.com/tnantoka/StringFilter",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "tnantoka": "[email protected]"
    },
    "social_media_url": "https://twitter.com/tnantoka",
    "platforms": {
        "ios": "9.1"
    },
    "requires_arc": true,
    "source": {
        "git": "https://github.com/tnantoka/StringFilter.git",
        "tag": "0.0.4",
        "submodules": true
    },
    "source_files": "StringFilter/**/*.{h,swift}",
    "pushed_with_swift_version": "3.0.1n"
}

Pin It on Pinterest

Share This