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

# range(of:options:locale:)

Returns the range of a substring in the attributed string, if it exists.

## Declaration

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

## Parameters

- `stringToFind`: The string to find.
- `options`: Options that affect the search behavior, such as case-insensivity, search direction, and regular expression matching.
- `locale`: The locale to use when searching, or nil to use the current locale. The default is nil.

## Return Value

Return Value The range where stringToFind exists in the attributed string, or nil if it isn’t present.
