---
title: "starts(with:)"
framework: swift
role: symbol
role_heading: Instance Method
path: "swift/bidirectionalcollection/starts(with:)-4972u"
---

# starts(with:)

Returns a Boolean value indicating whether the initial elements of the sequence are the same as the elements in the specified regex.

## Declaration

```swift
func starts(with regex: some RegexComponent) -> Bool
```

## Parameters

- `regex`: A regex to compare to this sequence.

## Return Value

Return Value true if the initial elements of the sequence matches the beginning of regex; otherwise, false.
