init(_:)
Creates a regular expression from the given string, using a dynamic capture list.
Declaration
init(_ pattern: String) throwsParameters
- pattern:
A string with regular expression syntax.
Discussion
Use this initializer to create a Regex instance from a regular expression that you have stored in pattern.
let simpleDigits = try Regex("[0-9]+")This initializer throws an error if pattern uses invalid regular expression syntax.
The output type of the new Regex is the dynamic AnyRegexOutput. If you know the capture structure of pattern ahead of time, use the init(_:as:) initializer instead.