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

# trimPrefix(_:)

Removes the initial elements that matches the given regex.

## Declaration

```swift
mutating func trimPrefix(_ regex: some RegexComponent)
```

## Parameters

- `regex`: The regex to remove from this collection.
