Skip to content
This repository has been archived by the owner on Oct 7, 2024. It is now read-only.

REPLACE

Dan Gorman edited this page Nov 29, 2018 · 2 revisions

The REPLACE Function

Function Group: Text

REPLACE replaces a segment of a string with another string.

Syntax

REPLACE(arg1, arg2, arg3, arg4)

  • arg1 is a string to be segmented
  • arg2 is the position to begin slicing the string at
  • arg3 is the number of characters to slice from the string
  • arg4 is string to replace the substring delineated by arg3 and arg4

Uses

Let's say we're given a response with an id:

{  
   "data":{  
      "ids":{  
         "id_1": "1anb4amca051"
      }
   }
}

If we replace the first four digits of the id with our own string, we can do so using REPLACE:

REPLACE(data.ids.id_1, 1, 4, "custom-id-")

This will return "custom-id-4amca051"

Notes

The second argument is inclusive, meaning the character at the specified position will be included in the segment.

Clone this wiki locally