Regex
public struct Regex
NSRegularExpression
convenience wrapper.
-
Create a new
Regex
with the givenpattern
andoptions
.Note
The initializer is an implicitely unwrapped optional for backward-compatibility reason, and will be made optional in a future release.
Declaration
Swift
public init!(_ pattern: String, options: NSRegularExpression.Options = [])
Parameters
pattern
The pattern to create the regex with.
options
The options to use when creating the regular expression.
-
Match the regex
Declaration
Swift
public func match(_ string: String, options: NSRegularExpression.MatchingOptions = []) -> Bool
Parameters
pattern
The string to match the regex against.
options
The options to use when matching the regular expressiona against the given string.