---
title: "prefixMatch(of:)"
framework: swift
role: symbol
role_heading: Instance Method
path: "swift/bidirectionalcollection/prefixmatch(of:)-2fwv6"
---

# prefixMatch(of:)

Matches part of the regex, starting at the beginning, where the regex is created by the given closure.

## Declaration

```swift
func prefixMatch<Output>(@RegexComponentBuilder of content: () -> some RegexComponent) -> Regex<Output>.Match?
```

## Parameters

- `content`: A closure that returns a regex to match against.

## Return Value

Return Value The match if there is one, or nil if none.
