<!--
{
  "availability" : [
    "iOS: 16.0.0 -",
    "iPadOS: 16.0.0 -",
    "macCatalyst: 16.0.0 -",
    "macOS: 13.0.0 -",
    "tvOS: 16.0.0 -",
    "visionOS: -",
    "watchOS: 9.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Swift",
  "identifier" : "/documentation/RegexBuilder/Capture/init(_:as:)-7rcvh",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "RegexBuilder"
    ],
    "preciseIdentifier" : "s:12RegexBuilder7CaptureV_2asACySs_qd__qd_0_qd_1_qd_2_qd_3_tGqd_4__AA9ReferenceVyqd__GtcSs_qd__qd_0_qd_1_qd_2_qd_3_tRsz17_StringProcessing0A9ComponentRd_4_qd___qd_0_qd_1_qd_2_qd_3_t0A6OutputRtd_4_r4_lufc"
  },
  "title" : "init(_:as:)"
}
-->

# init(_:as:)

Creates a capture for the given component using the specified
reference.

```
init<W, C1, C2, C3, C4>(_ component: some RegexComponent, as reference: Reference<W>) where Output == (Substring, W, C1, C2, C3, C4)
```

## Parameters

`component`

The regex component to capture.

`reference`

The reference to use for anything captured by
`component`.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)