REPLACE

All functions > STRING > REPLACE

Returns the string with all occurrences of a substring replaced with another substring.

Signatures

Returns: String with all occurrences replaced

REPLACE(string: VARCHAR, search: VARCHAR, [replacement: VARCHAR]) → VARCHAR
sql
ParameterTypeRequiredDescription
stringVARCHARYesString to search in
searchVARCHARYesSubstring to find
replacementVARCHARNoString to replace with (optional, defaults to empty string)

Notes

  • Replaces ALL occurrences, not just the first
  • Case-sensitive search
  • If replacement is omitted, removes the search string
  • If search string is not found, returns original string unchanged

Examples

FeatureQL
SELECT
    f1 := REPLACE('Hello World', 'o', 'X'),  -- Replace all 'o' with 'X'
    f2 := REPLACE('foo bar foo', 'foo', 'baz'),  -- Replace all occurrences
    f3 := REPLACE('foo-bar-baz', '-', '_'),  -- Replace dashes with underscores
    f4 := REPLACE('foo-bar-baz', '-'),  -- Remove dashes (omit replacement)
    f5 := REPLACE('ABCABC', 'ABC', 'X'),  -- Multiple replacements
    f6 := REPLACE('Hello', 'xyz', 'abc')  -- No match, no change
;
Result
f1 VARCHARf2 VARCHARf3 VARCHARf4 VARCHARf5 VARCHARf6 VARCHAR
HellX WXrldbaz bar bazfoo_bar_bazfoobarbazXXHello

Last update at: 2026/03/03 16:47:38
Last updated: 2026-03-03 16:48:19