---
schema_version: "1"
id: 925aeafc016210676654df07dcd1a1fd289c2fa1b9404afb4e50e02ebc345e72
title: REPLACE
collection: admin
version: current
locale: en-us
portal_url: https://docs.salesforce.com/admin/current/en-us/mktg/264-0-0/mcidp_data_mapping_formulas_replace.md
canonical_url: https://help.salesforce.com/s/articleView?id=mktg.mcidp_data_mapping_formulas_replace.htm&release=264.0.0&type=5
source_site: help.salesforce.com
content_type: documentation
content_hash: c2c4758120033cb9c1cf84966e7e1458b13dbcdebdbe8204b8bd754726c7ca02
description: Use the REPLACE function to replace characters or patterns in a string.
products:
  - Marketing
  - Marketing Cloud Intelligence
release: "264"
---
# REPLACE

Use the REPLACE function to replace characters or patterns in a string.

**Syntax: `REPLACE(sourceStr,pattern,targetStr)`**

For example, you can apply a replace function to media buy key values, replacing hyphens with spaces:

**Media buy key values:**

1. Summer-sale-123
2. New-deal-news
3. ABC publish

**Formula: `REPLACE(csv['media buy key'],'-',' ')`**

**Output:**

1. Summer sale 123
2. New deal news
3. ABC publish

All hyphens are removed and replaced with spaces. The third value with no hyphens remains the same.

The REPLACE function also supports the use of regular expressions. For example, the regular expression `\s` refers to all white-space characters. An additional backslash is added when using a regular expression with letters and numbers, such as `\s`, `\0`.

For example, you can apply the REPLACE function to replace spaces with hyphens.

**Formula: `REPLACE(csv['media buy key'],'\\s','-')`**

**Output**: 'media-buy-key'.

To use a special character, for example, an asterisk—considered a regular expression, as a regular character, add '`\\`' before the character.

For example:

**Formula: `REPLACE(csv['me*a buy key'],'\\*','di')`**

**Output**: 'media buy key'.

If the changes you want to apply to a string don’t require a regular expression, it’s recommended to use the SUBSTITUTE function.