# Regex Find Matches Iterator

> Iterate over matches of a regular expression in a string.

- ID: `regex_find_iterator`
- Type: Loop
- Category: [Regex](https://inventor.bot/docs/reference/blocks/regex.md)

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

**Inputs**

| Name | Required | Description | Value |
| --- | --- | --- | --- |
| `regex` | yes | Regular expression to search with. | e.g. `"(\\\\w+)"` |
| `text` | yes | Text to search through. | e.g. `"foo bar baz"` |
| `body` |  | Blocks to run for each match. | blocks: `func() { ... }` |

**Outputs**

| Name | Description | Value |
| --- | --- | --- |
| `iteration_number` | Current iteration (1-based). | e.g. `"1"` |
| `total_iterations` | Total number of matches found. | e.g. `"5"` |
| `match` | Matched text. | e.g. `"foo"` |

**Example**

```go
for match := range regex_find_iterator(Args{regex: "(\\\\w+)", text: "foo bar baz"}) {
	send_text_message(Args{channel_id: trigger.channel_id, message_content: "Match: " + match.match})
}
```