String
struct String
-
Gets the length of a string! Property only here for convenience
Declaration
Swift
public var length: Int -
Tells if the string is composed of only alphanumeric characters
Declaration
Swift
public var isAlphaNumeric: Bool -
Tells if the string is composed of digits only
Declaration
Swift
public var digitsOnly: Bool -
Tells if the string is composed of letters only
Declaration
Swift
public var lettersOnly: Bool -
Tells if the string contains only whitespaces and newlines
Declaration
Swift
public var isBlank: Bool
-
Trims a string from leading and trailing whitespaces and optionally newline characters
Parameter
Parameter newLine: if
true, will trim newline characters as well. Defaults tofalse.Returns
a trimmed
StringDeclaration
Swift
public func trim(shouldTrimNewLineCharacters newLine: Bool = false) -> StringParameters
newLineif
true, will trim newline characters as well. Defaults tofalse.Return Value
a trimmed
String -
Converts a
StringtoBoolLowercased
"true"will returntrue. Everything else isfalseReturns
BoolDeclaration
Swift
public func toBool() -> BoolReturn Value
Bool -
Turns a
Stringinto aDateParameter
Parameter format: the input format of the string. For example,
20161129
isStringDateFormat.YYYYMMDDReturns
a
DateDeclaration
Swift
public func toDate(stringDateFormat format: StringDateFormat = StringDateFormat.yyyyMMdd) -> Date?Parameters
formatthe input format of the string. For example, “20161129” is
StringDateFormat.YYYYMMDDReturn Value
a
Date -
Gets a substring from a string using a range. Function taken from http://stackoverflow.com/a/39509186/1296610
Parameter
Parameter range: The non inclusive range in the
Stringobject. For example,0..<5Returns
a substring as
StringDeclaration
Swift
public func substring(_ range: Range<Int>) -> StringParameters
rangeThe non inclusive range in the
Stringobject. For example,0..<5Return Value
a substring as
String
String Extension Reference