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

# prefixMatch(of:)

Returns a match if this string is matched by the given regex at its start.

## Declaration

```swift
func prefixMatch<R>(of regex: R) -> Regex<R.RegexOutput>.Match? where R : RegexComponent
```

## Parameters

- `regex`: The regular expression to match.

## Return Value

Return Value The match, if one is found. If there is no match, or a transformation in regex throws an error, this method returns nil.
