replace_string 函数
将一个子串的每次出现都替换为另一个子串。
语法
replace_string(text, old, new)string_replace(text, old, new)
参数与选项
text | 文本值,通常写在引号中。 |
|---|---|
old | 要替换的子串。 |
new | 替换后的文本。 |
示例
- 替换全部匹配项
replace_string('a-b-a', 'a', 'x')返回 x-b-x。
将一个子串的每次出现都替换为另一个子串。
replace_string(text, old, new)string_replace(text, old, new)text | 文本值,通常写在引号中。 |
|---|---|
old | 要替换的子串。 |
new | 替换后的文本。 |
replace_string('a-b-a', 'a', 'x')返回 x-b-x。