---
title: "tokens(for:)"
framework: naturallanguage
role: symbol
role_heading: Instance Method
path: "naturallanguage/nltokenizer/tokens(for:)"
---

# tokens(for:)

Tokenizes the string within the provided range.

## Declaration

```swift
@nonobjc func tokens(for range: Range<String.Index>) -> [Range<String.Index>]
```

## Parameters

- `range`: The range within the string that should be tokenzied.

## Return Value

Return Value Returns the ranges corresponding to the tokens for the tokenizer’s unit that intersect the given range.

## See Also

### Enumerating the tokens

- [enumerateTokens(in:using:)](naturallanguage/nltokenizer/enumeratetokens(in:using:).md)
- [tokenRange(at:)](naturallanguage/nltokenizer/tokenrange(at:).md)
- [tokenRange(for:)](naturallanguage/nltokenizer/tokenrange(for:).md)
