A swifty text converter.
Swift Shell Ruby Objective-C
Switch branches/tags
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
StringFilter.xcodeproj
StringFilter
Tests
.gitignore
.swift-version
.travis.yml
LICENSE
Package.swift
README.md
StringFilter.podspec
test

README.md

StringFilter

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)

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

CocoaPods

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