# Replace()

Replaces every occurrence of one substring with a different substring.

## Availability

<table>
  <tr>
    <td>Marketing Cloud Engagement</td>
    <td>✅ Yes</td>
  </tr>
  <tr>
    <td>Marketing Cloud Next</td>
    <td>✅ Yes</td>
  </tr>
</table>

This function became available in Marketing Cloud Next during the Summer ’26 release (API version 67.0).

## Syntax

```
Replace(sourceString,
        searchSubstring,
        replacementSubstring)
```

The `Replace()` function has three parameters:

- `sourceString` (string): Required. The string to search.
- `searchSubstring` (string): Required. The string to locate in `sourceString`.
- `replacementSubstring` (string): Required. The string to replace `searchSubstring` with.

## Usage

This example uses the [RegExMatch()](/docs/marketing/marketing-cloud-ampscript/references/mc-ampscript-string/mc-ampscript-reference-string-regex-match.md) function to identify a piece of text (in this case, the names of the seasons) in a source string. It then uses the `Replace()` function to replace the name of the season in the source string with the current season.

```
%%[
  Var @sourceText, @regex, @regexMatch, @currentSeason, @promoText
  Set @sourceText = "Special winter offers just for you!"
  Set @regex = "(?:fall|winter|spring|summer)"
  Set @regexMatch = RegExMatch(@sourceText, @regex, 0)
  Set @currentSeason = "spring"
  Set @promoText = Replace(@sourceText, @regexMatch, @currentSeason)
]%%
<p>%%=v(@promoText)=%%</p>

```

The example returns the promotional message with the string "winter" replaced with "spring."

```
Special spring offers just for you!
```
