Regex
Class uses NSRegularExpression internally and simplifies its usability.
-
Return match in a string. Optionally with index of capturing group
Declaration
Swift
class func matchInString(str: String, pattern: String, capturingGroupIdx: Int?) -> String?Parameters
strA string that will be matched.
patternA regex pattern.
Return Value
Stringthat matches pattern or nil. -
Return first match in a string.
Declaration
Swift
class func firstMatchInString(str: String, pattern: String) -> String?Parameters
strA string that will be matched.
patternA regexp pattern.
Return Value
Stringthat matches pattern or nil. -
Return all matches in a string.
Declaration
Swift
class func matchesInString(str: String, pattern: String) -> [String]Parameters
strA string that will be matched.
patternA regexp pattern.
Return Value
Array of
Stringss. If nothing found empty array is returned. -
Returns new
NSRegularExpressionobject.Declaration
Swift
private class func regexp(pattern: String) -> NSRegularExpression?Parameters
patternA regexp pattern.
Return Value
NSRegularExpressionobject or nil if it cannot be created. -
Method that substring string with passed range.
Declaration
Swift
private class func substring(str: String, range: NSRange) -> StringParameters
strA string that is source of substraction.
rangeA range that tells which part of
strwill be substracted.Return Value
A string contained in
range.
View on GitHub
Regex Class Reference