String
public extension String
Encode strings.
Version
1.8.0Date
29/04/2022-
Base 64 encoded string.
Declaration
Swift
var base64EncodedString: String? { get } -
URL encoded string.
Declaration
Swift
var urlEncodedString: String? { get } -
Undocumented
Declaration
Swift
static let space: String -
Undocumented
Declaration
Swift
static let linebreak: String -
Undocumented
Declaration
Swift
static let empty: String -
Undocumented
Declaration
Swift
static let plus: String -
Undocumented
Declaration
Swift
static let dot: String -
Undocumented
Declaration
Swift
static let tab: String -
Undocumented
Declaration
Swift
static let comma: String -
Undocumented
Declaration
Swift
static let dash: String -
Undocumented
Declaration
Swift
static let comment: String -
Undocumented
Declaration
Swift
static let leftSquareBracket: String -
Undocumented
Declaration
Swift
static let rightSquareBracket: String -
Undocumented
Declaration
Swift
static let forwardSlash: String -
Undocumented
Declaration
Swift
static let colon: String -
Undocumented
Declaration
Swift
static let semicolon: String -
Remove a specific suffix from the string.
Declaration
Swift
@discardableResult mutating func removeSuffix(_ suffix: String) -> BoolParameters
suffixThe suffix to be removed.
Return Value
Whether the suffix has been removed or not.
-
Remove a specific suffix from the string and return the new string
Declaration
Swift
func removingSuffix(_ suffix: String) -> StringParameters
suffixThe suffix to be removed.
Return Value
The suffix removed string.
-
Remove a specific prefix from the string.
Declaration
Swift
@discardableResult mutating func removePrefix(_ prefix: String) -> BoolParameters
prefixThe prefix to be removed.
Return Value
Whether the prefix has been removed or not.
-
Remove a specific prefix from the string and return the new string
Declaration
Swift
func removingPrefix(_ prefix: String) -> StringParameters
prefixThe prefix to be removed.
Return Value
The prefix removed string.
-
Remove all spaces in a string
Declaration
Swift
@discardableResult mutating func removeSpaces() -> BoolReturn Value
Whether spaces are removed or not
-
Remove all spaces in a string and return a new string
Declaration
Swift
func removingSpaces() -> StringReturn Value
The new string
-
Combine all sequencial spaces into one. Like “This is a test.” -> “This is a test”
Declaration
Swift
func combineSpaces() -> StringReturn Value
A new string with no sequencial spaces
-
Trim the string to a certain length
Declaration
Swift
func trimming(toLength length: Int) -> StringParameters
lengthThe new length
Return Value
The new string
-
Get a string who is word uppercased. Like “apple banana” -> “Apple Banana”
Declaration
Swift
@available(*, deprecated, message: "Use capitalized instead.") var wordUppercased: String { get } -
Get a string who is phrase uppercased. Like “apple banana” -> “Apple banana”
Declaration
Swift
var phraseUppercased: String { get } -
The default localization file.
Declaration
Swift
static let defaultLocalizationFilename: String -
Localize a string within the class using a localization file in the main bundle.
Declaration
Swift
func localizedString(withLocalizationFile filename: String = defaultLocalizationFilename) -> StringParameters
filenameThe string file used to localize the string.
Return Value
The localized string.
-
Localize a string using the the class name as the localization file within the bundle of a class.
Declaration
Swift
func localizedString(for anyClass: AnyClass) -> StringParameters
anyClassThe class used to find the localization file.
Return Value
The localized string.
-
Get all sub strings that matches a given regex.
Declaration
Swift
func allMatches(in string: String) -> [String]Parameters
stringThe whole string where the match will happen
Return Value
All matching sub strings
String Extension Reference