VeloDB Cloud
SQL Manual
Functions
string-functions
sub_replace

sub_replace

Description

Syntax:

VARCHAR sub_replace(VARCHAR str, VARCHAR new_str, INT start [, INT len])

This function replaces the substring that is of length len starting from start of str with new_str . If start and len are negative integers, it will return NULL. The default value of len is the length of new_str.

Example

mysql> select sub_replace("this is origin str","NEW-STR",1);
+-------------------------------------------------+
| sub_replace('this is origin str', 'NEW-STR', 1) |
+-------------------------------------------------+
| tNEW-STRorigin str                              |
+-------------------------------------------------+

mysql> select sub_replace("doris","***",1,2);
+-----------------------------------+
| sub_replace('doris', '***', 1, 2) |
+-----------------------------------+
| d***is                            |
+-----------------------------------+

Keywords

SUB_REPLACE