Handlebars replace
Handlebars replace: replaces every occurrence of a substring with another (case-sensitive).
Next
Runtime verified
Differs from official docs
Test scripts included
Replaces every occurrence of a substring with another (case-sensitive).
Syntax
{{replace subject search replacement [culture]}}
Returns string.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
subject |
string | Yes | String in which to replace text. |
search |
string | Yes | The substring to search for. |
replacement |
string | Yes | The replacement substring. |
culture |
string | No | BCP 47 locale code for culture-specific comparison. |
Example
Tested in a Marketing Cloud Next email on 2026-11-22:
{{replace "a-b-c" "-" "+"}}rendersa+b+c, as documented.{{replace "Aa" "a" "x"}}rendersxx. The documented result isAx.
Show Next test script
Differs from official docs
- The reference says the search string is matched case-sensitively. In Marketing Cloud Next (tested 2026-11-22):
{{replace "Aa" "a" "x"}}renderedxx: the uppercaseAwas replaced too. A case-sensitive match would giveAx. Details
Marketing Cloud Next
Differs from the documentation
{{replace "a-b-c" "-" "+"}} gives a+b+c. The search ignores case, although the documentation says it is case-sensitive: {{replace "Aa" "a" "x"}} renders xx instead of Ax. Tested 2026-11-22 by rendering in a Marketing Cloud Next email.
See also
- AMPscript
Replace— does a similar job in AMPscript, with a different call shape - Official reference