# Truncate Split String Iterator

> Iterate over a string by groups of a certain number of characters.

- ID: `truncate_split_string_iterator`
- Type: Loop
- Category: [Strings](https://inventor.bot/docs/reference/blocks/strings.md)

- Loop block: write `for item := range truncate_split_string_iterator(Args{...}) { ... }` and read the current item's outputs from `item`. See loops.

**Inputs**

| Name | Required | Description | Value |
| --- | --- | --- | --- |
| `text` | yes | String to split. |  |
| `split_after` | yes | Number of characters per group. | e.g. `"3"` |
| `sort` |  | Order of iteration. | `"Normal"`, `"Reverse"`, `"Random"`, `"Alphabetical"`, `"Reverse Alphabetical"`, `"Ascending Numeric"`, `"Descending Numeric"` |
| `body` |  | Blocks to run for each chunk. | blocks: `func() { ... }` |

**Outputs**

| Name | Description | Value |
| --- | --- | --- |
| `iteration_number` | 0-based iteration index. | e.g. `"0"` |
| `total_iterations` | Total number of chunks. | e.g. `"5"` |
| `split_string` | Current chunk. | e.g. `"abc"` |
| `is_last_iteration` | Whether this is the final chunk. | e.g. `"false"` |

**Example**

```go
for part := range truncate_split_string_iterator(Args{text: "...", split_after: 3}) {
	send_text_message(Args{
		channel_id:      trigger.channel_id,
		message_content: "Split String: " + part.split_string,
	})
}
```