---
title: "init(_:transform:)"
framework: regexbuilder
role: symbol
role_heading: Initializer
path: "regexbuilder/capture/init(_:transform:)-1t85c"
---

# init(_:transform:)

Creates a capture for the given component, transforming with the given closure.

## Declaration

```swift
init<W, C1, C2, NewCapture>(_ component: some RegexComponent, transform: @escaping (W) throws -> NewCapture) where Output == (Substring, NewCapture, C1, C2)
```

## Parameters

- `component`: The regex component to capture.
- `transform`: A closure that takes the substring matched by component and returns a new value to capture. If transform throws an error, matching is abandoned and the error is returned to the caller.
