String
extension String
extension String: URLConvertible
-
Retuns the localized string using the
CheetahDigitalUtils.Localizer.Declaration
Swift
public var localized: String { get }
-
Returns a
URLif theStringcan be used to initialize aURL, otherwise throws if an error was encountered.Throws
AURLError.invalidURLerror.Declaration
Swift
public func asURL() throws -> URLReturn Value
The
URLinitialized with theString. -
Returns the first extracted YouTube Id from the
String. If there is none, this will be nil.Declaration
Swift
var youtubeId: String? { get } -
Returns the first URL found in the
String. If there is none or the URL is invalid, this returns nil.Declaration
Swift
var firstUrl: URL? { get } -
Finds the first match given a regular expression pattern in the
String.Declaration
Swift
func firstMatchForRegEx(_ pattern: String) -> String?Parameters
patternThe regular expression pattern.
Return Value
The first match given a regular expression pattern in the
String. If there is none, this is nil. -
Returns an
NSAttributedStringinterpreting the HTML from theString.Declaration
Swift
var attributedHTMLString: NSAttributedString? { get } -
Returns the String stripped of CSS.
Declaration
Swift
var strippedCSS: String { get } -
Returns the String stripped of HTML, CSS and NBSP.
Declaration
Swift
var strippedHTML: String { get } -
Returns true if the
Stringis a valid URL along with scheme and host, otherwise it returns false.Declaration
Swift
var isValidURL: Bool { get } -
Returns true if the
Stringis a valid email address, otherwise it returns false.Declaration
Swift
var isValidEmail: Bool { get } -
Returns true if the
Stringis a valid phone number, otherwise it returns false.A valid phone number in this case is a
Stringwith no letters.Declaration
Swift
var isValidPhoneNumber: Bool { get } -
Returns true if the
Stringis blank, otherwise it returns false.A blank string is considered either empty or just having whitespace or new lines.
Declaration
Swift
var isBlank: Bool { get } -
Create a string period based on the given date strings.
If both parameters or the startDate are invalid, this method will just throw an empty string. But if endDate is invalid this will instead used the word Onwards.
Declaration
Swift
static func createPeriod(startDate: String, endDate: String, dateFormat: String, resultFormat: String) -> StringParameters
startDateThe beginning of the period.
endDateThe end of the period.
dateFormatThe format of the given dates.
resultFormatThe resulting format of the dates in the period string.
Return Value
A string period.
String Extension Reference