<!--
{
  "availability" : [
    "iOS: 12.0.0 -",
    "iPadOS: 12.0.0 -",
    "macCatalyst: 12.0.0 -",
    "macOS: 10.14.0 -",
    "tvOS: 12.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 5.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "NaturalLanguage",
  "identifier" : "/documentation/NaturalLanguage/NLTagger/tokenRange(at:unit:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Natural Language",
      "NaturalLanguage"
    ],
    "preciseIdentifier" : "s:So8NLTaggerC15NaturalLanguageE10tokenRange2at4unitSnySS5IndexVGAH_So11NLTokenUnitVtF"
  },
  "title" : "tokenRange(at:unit:)"
}
-->

# tokenRange(at:unit:)

Returns the range of the linguistic unit containing the specified character index.

```
@nonobjc func tokenRange(at index: String.Index, unit: NLTokenUnit) -> Range<String.Index>
```

## Parameters

`unit`

The linguistic unit. For possible values, see [`NLTokenUnit`](/documentation/NaturalLanguage/NLTokenUnit).

## Return Value

The range of the substring for the linguistic unit.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)