VeloDB Cloud
SQL Manual
SQL Functions
String Functions
REPLACE_EMPTY

replace_empty

description

Syntax

Since 2.1.5

VARCHAR REPLACE_EMPTY (VARCHAR str, VARCHAR old, VARCHAR new)

Replace all old substrings in str string with new string.

Unlike the REPLACE() function, when old is an empty string, the new string is inserted before each character of the str string and at the end of the str string.

Other than that, the other behaviors are exactly the same as the REPLACE() function.

This function is mainly used for compatibility with Presto and Trino, and its behavior is exactly the same as the REPLACE() function in Presto and Trino.

example

mysql> select replace_empty("http://www.baidu.com:9090", "9090", "");
+------------------------------------------------------+
| replace('http://www.baidu.com:9090', '9090', '') |
+------------------------------------------------------+
| http://www.baidu.com:                                |
+------------------------------------------------------+

mysql> select replace_empty("abc", '', 'xyz');
+---------------------------------+
| replace_empty('abc', '', 'xyz') |
+---------------------------------+
| xyzaxyzbxyzcxyz                 |
+---------------------------------+

mysql> select replace_empty("", "", "xyz");
+------------------------------+
| replace_empty('', '', 'xyz') |
+------------------------------+
| xyz                          |
+------------------------------+

keywords

REPLACE_EMPTY