init(_:transform:)
Creates a capture for the given component, attempting to transform with the given closure.
Declaration
init<W, C1, NewCapture>(@RegexComponentBuilder _ componentBuilder: () -> some RegexComponent, transform: @escaping (W) throws -> NewCapture?) where Output == (Substring, NewCapture, C1)Parameters
- componentBuilder:
A builder closure that generates a regex component to capture.
- transform:
A closure that takes the substring matched by
componentand returns a new value to capture, ornilif matching should proceed, backtracking if allowed. Iftransformthrows an error, matching is abandoned and the error is returned to the caller.