<!--
{
  "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/Lookahead",
  "metadataVersion" : "0.1.0",
  "role" : "Structure",
  "symbol" : {
    "kind" : "Structure",
    "modules" : [
      "RegexBuilder"
    ],
    "preciseIdentifier" : "s:12RegexBuilder9LookaheadV"
  },
  "title" : "Lookahead"
}
-->

# Lookahead

A regex component that allows a match to continue only if its contents
match at the given location.

```
struct Lookahead<Output>
```

## Overview

A lookahead is a zero-length assertion that its included regex matches at
a particular position. Lookaheads do not advance the overall matching
position in the input string — once a lookahead succeeds, matching continues
in the regex from the same position.

## Topics

### Initializers

[`init<R>(() -> R)`](/documentation/RegexBuilder/Lookahead/init(_:)-2yv8x)

Creates a lookahead from the regex generated by the given builder closure.

[`init<R>(R)`](/documentation/RegexBuilder/Lookahead/init(_:)-4s5w2)

Creates a lookahead from the given regex component.

## Relationships

### Conforms To

[`Escapable`](/documentation/Swift/Escapable)

[`Copyable`](/documentation/Swift/Copyable)

[`RegexComponent`](/documentation/Swift/RegexComponent)

---

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)