Regex
public struct Regex
                A Regex represents a compiled regular expression that can be applied to
String objects to search for (and replace) matched patterns.
- 
                  
                  
Attempts to create a
Regexwith the providedpattern. If this fails, a tuple(nil, NSError)is returned. If it succeeds, a tuple(Regex, nil)is returned.Declaration
Swift
public static func create(pattern:String) -> (Regex?, NSError?) - 
                  
                  
Creates a
Regexwith the providedStringas its pattern. If the pattern is invalid, this function callsfatalError(). Hence, it is recommended that you useRegex.create()for more descriptive error messages.Declaration
Swift
public init(_ p:String)Parameters
pA string containing a regular expression pattern.
 - 
                  
                  
Creates a
Regexwith the providedStringas its pattern. If the pattern is invalid, this function initializes anNSErrorinto the providedNSErrorPointer.Regex.create()is recommended, as it wraps this constructor and handles theNSErrorPointerdance for you.Declaration
Swift
public init (pattern p:String) throwsParameters
pA string containing a regular expression pattern.
errorAn
NSErrorPointerthat will contain anNSErrorif initialization fails. - 
                  
                  
Searches in
stringfor the regular expression pattern represented by the receiver.Declaration
Swift
public func match (string:String) -> MatchResultParameters
stringThe string in which to search for matches.
 - 
                  
                  
Searches
stringfor the regular expression pattern represented by the receiver. Any matches are replaced using the providedreplacementstring, which can contain substitution patterns like"$1", etc.Declaration
Swift
public func replaceMatchesIn (string:String, with replacement:String) -> (replacements:Int, string:String)Parameters
stringThe string to search.
replacementThe replacement pattern to apply to any matches.
Return Value
A 2-tuple containing the number of replacements made and the transformed search string.
 - 
                  
                  
Searches
stringfor the regular expression pattern represented by the receiver. Any matches are replaced using the providedreplacementstring, which can contain substitution patterns like"$1", etc.Declaration
Swift
public func replaceMatchesIn (string:String, with replacement:String) -> StringParameters
stringThe string to search.
replacementThe replacement pattern to apply to any matches.
Return Value
The transformed search string.
 
View on GitHub
        Regex Struct Reference