<!--
{
  "availability" : [
    "iOS: 16.0.0 -",
    "iPadOS: 16.0.0 -",
    "macCatalyst: 16.0.0 -",
    "macOS: 13.0.0 -",
    "tvOS: 16.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 9.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Swift",
  "identifier" : "/documentation/Swift/Regex/init(_:)-92siq",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "Swift"
    ],
    "preciseIdentifier" : "s:17_StringProcessing5RegexVA2A03AnyC6OutputVRszlEyACyAEGACyqd__Gclufc"
  },
  "title" : "init(_:)"
}
-->

# init(_:)

Creates a regular expression with a dynamic capture list from the given
regular expression.

```
init<OtherOutput>(_ regex: Regex<OtherOutput>)
```

## Parameters

`regex`

A regular expression to convert to use a dynamic
capture list.

## Discussion

You can use this initializer to convert a `Regex` with strongly-typed
captures into a `Regex` with `AnyRegexOutput` as its output type.

---

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)