跳到主要内容

sub_replace

sub_replace

description

Syntax

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

返回用new_str字符串替换str中从start开始长度为len的新字符串。 其中start,len为负整数,返回NULL, 且len的默认值为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