SwiftString alternatives and similar libraries
Based on the "Text" category.
Alternatively, view SwiftString alternatives based on common mentions on social networks and blogs.
-
PhoneNumberKit
A Swift framework for parsing, formatting and validating international phone numbers. Inspired by Google's libphonenumber. -
ZSSRichTextEditor
A beautiful rich text WYSIWYG editor for iOS with a syntax highlighted source view -
Twitter Text Obj
Twitter Text Libraries. This code is used at Twitter to tokenize and parse text to meet the expectations for what can be used on the platform. -
FontAwesomeKit
Icon font library for iOS. Currently supports Font-Awesome, Foundation icons, Zocial, and ionicons. -
TwitterTextEditor
A standalone, flexible API that provides a full-featured rich text editor for iOS applications. -
RichEditorView
DISCONTINUED. RichEditorView is a simple, modular, drop-in UIView subclass for Rich Text Editing. -
SwiftyMarkdown
Converts Markdown files and strings into NSAttributedStrings with lots of customisation options. -
Atributika
Convert text with HTML tags, links, hashtags, mentions into NSAttributedString. Make them clickable with UILabel drop-in replacement. -
SwiftIconFont
Icons fonts for iOS (Font Awesome 5, Iconic, Ionicon, Octicon, Themify, MapIcon, MaterialIcon, Foundation 3, Elegant Icon, Captain Icon) -
NSStringEmojize
A category on NSString to convert Emoji Cheat Sheet codes to their equivalent Unicode characters -
Mustard
🌭 Mustard is a Swift library for tokenizing strings when splitting by whitespace doesn't cut it. -
Heimdall
Heimdall is a wrapper around the Security framework for simple encryption/decryption operations. -
AttributedTextView
Easiest way to create an attributed UITextView (with support for multiple links and from html)
InfluxDB - Purpose built for real-time analytics at any scale.
* Code Quality Rankings and insights are calculated and provided by Lumnify.
They vary from L1 to L5 with "L5" being the highest.
Do you think we are missing an alternative of SwiftString or a related project?
README
SwiftString
SwiftString is a lightweight string extension for Swift. This library was motivated by having to search StackOverflow for common string operations, and wanting them to be in one place with test coverage.
Installation
SwiftString is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod "SwiftString"
Usage
import SwiftString
Methods
between(left, right)
"<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
camelize()
"os version".camelize() // "osVersion"
"HelloWorld".camelize() // "helloWorld"
"someword With Characters".camelize() // "somewordWithCharacters"
"data_rate".camelize() // "dataRate"
"background-color".camelize() // "backgroundColor"
capitalize()
"hello world".capitalize() // "Hello World"
chompLeft(string)
"foobar".chompLeft("foo") // "bar"
"foobar".chompLeft("bar") // "foo"
chompRight(string)
"foobar".chompRight("bar") // "foo"
"foobar".chompRight("foo") // "bar"
collapseWhitespace()
" String \t libraries are \n\n\t fun\n! ".collapseWhitespace() // "String libraries are fun !")
contains(substring)
"foobar".contains("foo") // true
"foobar".contains("bar") // true
"foobar".contains("something") // false
count(string)
"hi hi ho hey hihey".count("hi") // 3
decodeHTML()
"The Weekend ‘King Of The Fall’".decodeHTML() // "The Weekend ‘King Of The Fall’"
"<strong> 4 < 5 & 3 > 2 .</strong> Price: 12 €. @ ".decodeHTML() // "<strong> 4 < 5 & 3 > 2 .</strong> Price: 12 €. @ "
"this is so "good"".decodeHTML() // "this is so \"good\""
endsWith(suffix)
"hello world".endsWith("world") // true
"hello world".endsWith("foo") // false
ensureLeft(prefix)
"/subdir".ensureLeft("/") // "/subdir"
"subdir".ensureLeft("/") // "/subdir"
ensureRight(suffix)
"subdir/".ensureRight("/") // "subdir/"
"subdir".ensureRight("/") // "subdir/"
indexOf(substring)
"hello".indexOf("hell"), // 0
"hello".indexOf("lo"), // 3
"hello".indexOf("world") // nil
initials()
"First".initials(), // "F"
"First Last".initials(), // "FL"
"First Middle1 Middle2 Middle3 Last".initials() // "FMMML"
initialsFirstAndLast()
"First Last".initialsFirstAndLast(), // "FL"
"First Middle1 Middle2 Middle3 Last".initialsFirstAndLast() // "FL"
isAlpha()
"fdafaf3".isAlpha() // false
"afaf".isAlpha() // true
"dfdf--dfd".isAlpha() // false
isAlphaNumeric()
"afaf35353afaf".isAlphaNumeric() // true
"FFFF99fff".isAlphaNumeric() // true
"99".isAlphaNumeric() // true
"afff".isAlphaNumeric() // true
"-33".isAlphaNumeric() // false
"aaff..".isAlphaNumeric() // false
isEmpty()
" ".isEmpty() // true
"\t\t\t ".isEmpty() // true
"\n\n".isEmpty() // true
"helo".isEmpty() // false
isNumeric()
"abc".isNumeric() // false
"123a".isNumeric() // false
"1".isNumeric() // true
"22".isNumeric() // true
"33.0".isNumeric() // true
"-63.0".isNumeric() // true
join(sequence)
",".join([1,2,3]) // "1,2,3"
",".join([]) // ""
",".join(["a","b","c"]) // "a,b,c"
"! ".join(["hey","who are you?"]) // "hey! who are you?"
latinize()
"šÜįéïöç".latinize() // "sUieioc"
"crème brûlée".latinize() // "creme brulee"
lines()
"test".lines() // ["test"]
"test\nsentence".lines() // ["test", "sentence"]
"test \nsentence".lines() // ["test ", "sentence"]
pad(n, string)
"hello".pad(2) // " hello "
"hello".pad(1, "\t") // "\thello\t"
padLeft(n, string)
"hello".padLeft(10) // " hello"
"what?".padLeft(2, "!") // "!!what?"
padRight(n, string)
"hello".padRight(10) // "hello "
"hello".padRight(2, "!") // "hello!!"
startsWith(prefix)
"hello world".startsWith("hello") // true
"hello world".startsWith("foo") // false
split(separator)
"hello world".split(" ")[0] // "hello"
"hello world".split(" ")[1] // "world"
"helloworld".split(" ")[0] // "helloworld"
times(n)
"hi".times(3) // "hihihi"
" ".times(10) // " "
toBool()
"asdwads".toBool() // nil
"true".toBool() // true
"false".toBool() // false
toFloat()
"asdwads".toFloat() // nil
"2.00".toFloat() // 2.0
"2".toFloat() // 2.0
toInt()
"asdwads".toInt() // nil
"2.00".toInt() // 2
"2".toInt() // 2
toDate()
"asdwads".toDate() // nil
"2014-06-03".toDate() // NSDate
toDateTime()
"asdwads".toDateTime() // nil
"2014-06-03 13:15:01".toDateTime() // NSDate
toDouble()
"asdwads".toDouble() // nil
"2.00".toDouble() // 2.0
"2".toDouble() // 2.0
trimmedLeft()
" How are you? ".trimmedLeft() // "How are you? "
trimmedRight()
" How are you? ".trimmedRight() // " How are you?"
trimmed()
" How are you? ".trimmed() // "How are you?"
slugify()
"Global Thermonuclear Warfare".slugify() // "global-thermonuclear-warfare"
"Crème brûlée".slugify() // "creme-brulee"
stripPunctuation()
"My, st[ring] *full* of %punct)".stripPunctuation() // "My string full of punct"
substring(startIndex, length)
"hello world".substring(0, length: 1) // "h"
"hello world".substring(0, length: 11) // "hello world"
[subscript]
"hello world"[0...1] // "he"
"hello world"[0..<1] // "h"
"hello world"[0] // "h"
"hello world"[0...10] // "hello world"
Author
Andrew Mayne, [email protected]
License
SwiftString is available under the MIT license. See the LICENSE file for more info.
*Note that all licence references and agreements mentioned in the SwiftString README section above
are relevant to that project's source code only.