replace

Function replace 

Source
pub fn replace(args: &[Value]) -> Result<Value, RuntimeError>
Expand description

替换字符串中的所有匹配项

§功能

将字符串中所有出现的子字符串替换为新的字符串。

§参数

  • string: String - 原始字符串
  • from: String - 要被替换的子字符串
  • to: String - 替换后的新字符串

§返回值

String - 替换后的字符串

§示例

Set text "Hello World"
Set replaced Replace(text, "World", "Aether")  # "Hello Aether"
Set text "foo bar foo"
Set replaced Replace(text, "foo", "baz")       # "baz bar baz"
Set path "C:\\Users\\Name"
Set fixed Replace(path, "\\", "/")             # "C:/Users/Name"