---
title: "trimPrefix(_:)"
framework: swift
role: symbol
role_heading: Instance Method
path: "swift/rangereplaceablecollection/trimprefix(_:)-2hzf1"
---

# trimPrefix(_:)

Removes the initial elements matching the regex from the start of this collection, if the initial elements match, using the given closure to create the regex.

## Declaration

```swift
mutating func trimPrefix(@RegexComponentBuilder _ content: () -> some RegexComponent)
```

## Parameters

- `content`: A closure that returns the regex to search for at the start of this collection.
