String

public extension String

Encode strings.

Author

Adamas

Version

1.8.0

Date

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
  • dot

    Undocumented

    Declaration

    Swift

    static let dot: String
  • tab

    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) -> Bool

    Parameters

    suffix

    The 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) -> String

    Parameters

    suffix

    The 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) -> Bool

    Parameters

    prefix

    The 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) -> String

    Parameters

    prefix

    The prefix to be removed.

    Return Value

    The prefix removed string.

  • Remove all spaces in a string

    Declaration

    Swift

    @discardableResult
    mutating func removeSpaces() -> Bool

    Return Value

    Whether spaces are removed or not

  • Remove all spaces in a string and return a new string

    Declaration

    Swift

    func removingSpaces() -> String

    Return Value

    The new string

  • Combine all sequencial spaces into one. Like “This is a test.” -> “This is a test”

    Declaration

    Swift

    func combineSpaces() -> String

    Return Value

    A new string with no sequencial spaces

  • Trim the string to a certain length

    Declaration

    Swift

    func trimming(toLength length: Int) -> String

    Parameters

    length

    The 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) -> String

    Parameters

    filename

    The 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) -> String

    Parameters

    anyClass

    The 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

    string

    The whole string where the match will happen

    Return Value

    All matching sub strings