<!--
{
  "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:)-3466q",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "RegexBuilder"
    ],
    "preciseIdentifier" : "s:12RegexBuilder7CaptureV_2asACySs_qd__qd_0_qd_1_qd_2_qd_3_qd_4_tGqd_5__AA9ReferenceVyqd__GtcSs_qd__qd_0_qd_1_qd_2_qd_3_qd_4_tRsz17_StringProcessing0A9ComponentRd_5_qd___qd_0_qd_1_qd_2_qd_3_qd_4_t0A6OutputRtd_5_r5_lufc"
  },
  "title" : "init(_:as:)"
}
-->

# init(_:as:)

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

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

## 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)