strings.replace() 函数
strings.replace() 用指定的替换字符串替换第一次 i 个不重叠的子字符串实例。
函数类型签名
(i: int, t: string, u: string, v: string) => string
有关更多信息,请参见 Function type signatures。
参数
v
(必填) 要搜索的字符串值。
t
(必填) 要替换的子字符串值。
你
(必需)
t的i个实例的替换。
我
(必需)
要替换的非重叠 t 匹配的数量。
示例
替换特定数量的字符串匹配
import "sampledata"
import "strings"
sampledata.string()
|> map(fn: (r) => ({r with _value: strings.replace(v: r._value, t: "p", u: "XX", i: 2)}))