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

keywords

  1. SUB_REPLACE