---
title: "range(of:options:range:locale:)"
framework: swift
role: symbol
role_heading: Instance Method
path: "swift/stringprotocol/range(of:options:range:locale:)"
---

# range(of:options:range:locale:)

Finds and returns the range of the first occurrence of a given string within a given range of the String, subject to given options, using the specified locale, if any.

## Declaration

```swift
func range<T>(of aString: T, options mask: String.CompareOptions = [], range searchRange: Range<Self.Index>? = nil, locale: Locale? = nil) -> Range<Self.Index>? where T : StringProtocol
```
