replace_string()

将所有字符串匹配项替换为指定字符串。

弃用的别名:replace()

若要替换多个字符串,请参阅 replace_strings()

语法

replace_string(text,lookup,rewrite)

详细了解语法约定

参数

客户 类型​​ 必需 说明
text string 源字符串。
lookup string 要替换的字符串。
重写 string 替换字符串。

返回

在使用 rewrite 计算结果替换 lookup 的所有匹配项后返回 text。 匹配项不会重叠。

示例

range x from 1 to 5 step 1
| extend str=strcat('Number is ', tostring(x))
| extend replaced=replace_string(str, 'is', 'was')

输出

x str 替换的内容
1 数值为 1.000000 数值曾为 1.000000
2 数值为 2.000000 数值曾为 2.000000
3 数值为 3.000000 数值曾为 3.000000
4 数值为 4.000000 数值曾为 4.000000
5 数值为 5.000000 数值曾为 5.000000