<!--
{
  "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/RegexOutput",
  "metadataVersion" : "0.1.0",
  "role" : "Type Alias",
  "symbol" : {
    "kind" : "Type Alias",
    "modules" : [
      "Swift"
    ],
    "preciseIdentifier" : "s:17_StringProcessing5RegexV0C6Outputa"
  },
  "title" : "Regex.RegexOutput"
}
-->

# Regex.RegexOutput

The output type for this regular expression.

```
typealias RegexOutput = Output
```

## Discussion

A `Regex` instance’s output type depends on whether the `Regex` has
captures and how it is created.

- A `Regex` created from a string using the `init(_:)` initializer
  has an output type of [`AnyRegexOutput`](/documentation/Swift/AnyRegexOutput), whether it has captures or
  not.
- A `Regex` without captures created from a regex literal, the
  `init(_:as:)` initializer, or a `RegexBuilder` closure has a
  `Substring` output type, where the substring is the portion of the
  string that was matched.
- A `Regex` with captures created from a regex literal or the
  `init(_:as:)` initializer has a tuple of substrings as its output
  type. The first component of the tuple is the full portion of the string
  that was matched, with the remaining components holding the captures.

---

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)