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
str
A string that will be matched.
pattern
A regex pattern.
Return Value
String
that matches pattern or nil. -
Return first match in a string.
Declaration
Swift
class func firstMatchInString(str: String, pattern: String) -> String?
Parameters
str
A string that will be matched.
pattern
A regexp pattern.
Return Value
String
that matches pattern or nil. -
Return all matches in a string.
Declaration
Swift
class func matchesInString(str: String, pattern: String) -> [String]
Parameters
str
A string that will be matched.
pattern
A regexp pattern.
Return Value
Array of
Strings
s. If nothing found empty array is returned. -
Returns new
NSRegularExpression
object.Declaration
Swift
private class func regexp(pattern: String) -> NSRegularExpression?
Parameters
pattern
A regexp pattern.
Return Value
NSRegularExpression
object or nil if it cannot be created. -
Method that substring string with passed range.
Declaration
Swift
private class func substring(str: String, range: NSRange) -> String
Parameters
str
A string that is source of substraction.
range
A range that tells which part of
str
will be substracted.Return Value
A string contained in
range
.