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

1. mysql> select sub_replace("this is origin str","NEW-STR",1);
2. +-------------------------------------------------+
3. | sub_replace('this is origin str', 'NEW-STR', 1) |
4. +-------------------------------------------------+
5. | tNEW-STRorigin str                              |
6. +-------------------------------------------------+

8. mysql> select sub_replace("doris","***",1,2);
9. +-----------------------------------+
10. | sub_replace('doris', '***', 1, 2) |
11. +-----------------------------------+
12. | d***is                            |
13. +-----------------------------------+

keywords

1. SUB_REPLACE