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

# NegativeLookahead

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

```
struct NegativeLookahead<Output>
```

## Overview

A negative lookahead is a zero-length assertion that its included regex
does not match 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/NegativeLookahead/init(_:)-3fsnx)

Creates a negative lookahead from the given regex component.

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

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

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