> ## Documentation Index
> Fetch the complete documentation index at: https://learn.workflow.dog/llms.txt
> Use this file to discover all available pages before exploring further.

# Replace Text

> Replace literal text or regex matches inside a string.

The **Replace Text** action searches a string and substitutes the matching
content. It supports straightforward literal replacement and reusable regular
expressions.

## Inputs

| Input                     | Type               | Required  | Description                                                     |
| ------------------------- | ------------------ | --------- | --------------------------------------------------------------- |
| **Text**                  | String             | Yes       | The text to modify.                                             |
| **Use Regex**             | Boolean            | Yes       | Shows either the literal-text or regex inputs.                  |
| **Search Text**           | String             | Sometimes | Literal characters to replace when **Use Regex** is off.        |
| **Ignore Case**           | Boolean            | No        | Makes literal matching case-insensitive. Defaults to `false`.   |
| **Only First Occurrence** | Boolean            | No        | Replaces only the first literal match. Defaults to `false`.     |
| **Whole Words**           | Boolean            | No        | Limits literal matches to word boundaries. Defaults to `false`. |
| **Search Pattern**        | Regular expression | Sometimes | Pattern used when **Use Regex** is on.                          |
| **Replacement**           | String             | Yes       | Text inserted for each match. Empty text removes matches.       |

## Outputs

| Output       | Type   | Description                           |
| ------------ | ------ | ------------------------------------- |
| **Replaced** | String | The text after replacements are made. |

## Literal replacement

Literal mode escapes regex punctuation in **Search Text**, so a value such as
`.` matches a period instead of any character. By default, every exact match is
replaced.

For example, replace `draft` with `final` in:

```text theme={null}
draft-report-draft
```

The default result is `final-report-final`. Turn on **Only First Occurrence** to
produce `final-report-draft`.

<Note>
  **Whole Words** uses regex word boundaries. It works best for letters,
  numbers, and underscores; punctuation and some non-Latin word boundaries may
  behave differently than natural-language word detection.
</Note>

## Regex replacement

Regex mode uses the flags configured on **Search Pattern**. A regex with the
`g` flag replaces every match; without `g`, only the first match is replaced.
Replacement tokens supported by JavaScript are available, including `$&` for
the complete match and `$1`, `$2`, and so on for capture groups.

For example, use this pattern:

```text theme={null}
(\d{4})-(\d{2})-(\d{2})
```

And this replacement:

```text theme={null}
$2/$3/$1
```

The value `2026-07-24` becomes `07/24/2026`.

<Warning>
  Literal-mode options disappear when **Use Regex** is enabled. Configure case
  sensitivity, global matching, and boundaries in the **Regular Expression**
  action instead.
</Warning>
