String

@frozen
public extension String
  • Checks if a string is made of only digits.

    Declaration

    Swift

    var isDigits: Bool { get }
  • Checks if the String contains any digit.

    Declaration

    Swift

    var containsDigit: Bool { get }
  • Checks if the string starts with a capital letter.

    Declaration

    Swift

    var isCapitalized: Bool { get }
  • Checks if a string is made of only lowercase charaters.

    Declaration

    Swift

    var isLowercased: Bool { get }
  • The string contains at least one lowecase character.

    Declaration

    Swift

    var containsLowercase: Bool { get }
  • Checks if a string is made of only uppercase charaters.

    Declaration

    Swift

    var isUppercased: Bool { get }
  • The string contains at least one uppercase character.

    Declaration

    Swift

    var containsUppercase: Bool { get }
  • Returns a String of random numbers.

    Declaration

    Swift

    static func randomDigits(length: Int) -> String

    Parameters

    length

    The desired length of the string.

    Return Value

    A string long as the desired length made of random digits.

  • Returns a string

    Declaration

    Swift

    static func random(
      length: Int,
      includeLowercaseLetters: Bool = true,
      includeCapitalLetters: Bool = true,
      includeDigits: Bool = true,
      additionalCharacters: String = ""
    ) -> String

    Parameters

    length

    The desired length of the string.

    includeLowercaseLetters

    If true, includes abcdefghijklmnopqrstuvwxyz in allowed characters.

    includeCapitalLetters

    If true, includes ABCDEFGHIJKLMNOPQRSTUVWXYZ in allowed characters.

    includeDigits

    If true, includes 0123456789 in allowed characters.

    additionalCharacters

    A list of aditional characters to include.

    Return Value

    A String as long as the desired length, made of the allowed characters. If no character type is allowed, and no additionalCharacters are passed, returns an empty string.

  • Clears the string. Sets it to an empty string.

    Declaration

    Swift

    mutating func clear()