SQLite replace() Function

The SQLite replace() function replaces all occurrences of a specified substring in a specified string with a new substring and returns the result.

Syntax

Here is the syntax of the SQLite replace() function:

replace(string, search_string, replacement)

Parameters

string

Required. The string to search and replace in.

search_string

Required. The string to search for.

replacement

Required. The string to replace search_string with.

Return value

The SQLite function replace() replaces all substrings search_string in the string string with replacement and returns the result.

Examples

This example shows how to use replace() to replace parts of a string:

SELECT
    replace('Hello World', 'World', 'Alice'),
    replace('Hello World', 'l', 'L'),
    replace('Hello World', 'W', 'w');
replace('Hello World', 'World', 'Alice') = Hello Alice
        replace('Hello World', 'l', 'L') = HeLLo WorLd
        replace('Hello World', 'W', 'w') = Hello world