---
schema_version: "1"
id: dade357812047a21f5730533ca19c299062a01ebc0d164ee4ca85cd5affea19a
title: Replace()
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/marketing-cloud/ampscript/references/string/mc-ampscript-reference-string-replace.md
canonical_url: https://developer.salesforce.com/docs/marketing/marketing-cloud-ampscript/references/mc-ampscript-string/mc-ampscript-reference-string-replace.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: f7c11f86565038fd8fa2649b31a911184ff5ebcefa4ef4392d8230e563995bce
products:
  - AMPscript for Marketing Cloud
  - Marketing Cloud
---
# 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()](https://developer.salesforce.com/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!
```
