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

# init(as:_:)

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

```
init<W, C1, C2, C3, C4, C5, C6, C7, C8>(as reference: Reference<W>, @RegexComponentBuilder _ componentBuilder: () -> some RegexComponent) where Output == (Substring, W, C1, C2, C3, C4, C5, C6, C7, C8)
```

## Parameters

`reference`

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

`componentBuilder`

A builder closure that generates a regex
component to capture.

---

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)