Skip to main content

$replaceAll

The $replaceAll operator replaces all occurrences of a substring with a new substring in the original string.

Input

  • An array containing exactly three string values: the original string, the substring to replace, and the new substring

Output

  • The original string with all occurrences of the specified substring replaced

Examples

Basic Replace All

{
  "$replaceAll": [
    "Hello, world! Hello, universe!",
    "Hello",
    "Hi"
  ]
}
Result: "Hi, world! Hi, universe!"

Field Value

{
  "$replaceAll": [
    {
      "$input": "text"
    },
    "old_word",
    "new_word"
  ]
}
Result: The text field with all occurrences of “old_word” replaced with “new_word”