# Regex Replace

> Replace all matches of a regular expression in a string.

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

**Inputs**

| Name | Required | Description | Value |
| --- | --- | --- | --- |
| `regex` | yes | Regular expression to search with. | e.g. `"(foo)"` |
| `text` | yes | Text to run the regex against. | e.g. `"foo bar baz"` |
| `replacement` |  | Text to replace matches with. | e.g. `"qux"` |

**Outputs**

| Name | Description | Value |
| --- | --- | --- |
| `replaced_string` | String after all replacements. | e.g. `"qux bar baz"` |

**Example**

```go
regexReplace := regex_replace(Args{regex: "(foo)", text: "foo bar baz"})
send_text_message(Args{
	channel_id:      trigger.channel_id,
	message_content: "Replaced String: " + regexReplace.replaced_string,
})
```