---
title: "firstMatch(of:)"
framework: swift
role: symbol
role_heading: Instance Method
path: "swift/bidirectionalcollection/firstmatch(of:)-6v8ci"
---

# firstMatch(of:)

Returns the first match for the regex within this collection, where the regex is created by the given closure.

## Declaration

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

## Parameters

- `content`: A closure that returns the regex to search for.

## Return Value

Return Value The first match for the regex created by content in this collection, or nil if no match is found.
