Skip to content

StringReplace

将目标字符串 s 中所有的子串 p 替换成字符串 r。

Lua字符串的字节下标是从 1 开始的

业务属性

属性含义说明输入限定示例值
enable是否启用该控件,未启用时不编译是否编译选择值启用
name控件返回值命名控件输出值变量名常量repStr
text与控件关联的文本设计页控件显示常量StringRep
input输入字符串常量/流程变量#{str}
childString字符串子串常量/流程变量abc
replacement替换字符串常量/流程变量#{rStr}

使用示例

输入常量

参数输入:hello world,查找子串:world,替换为orapis

img_27.png

输出控件返回resultStrdata属性为:

json
{
  "resultStr": "#{resultStr}"
}
{
  "resultStr": "#{resultStr}"
}
img_28.png

使用curl请求接口:

$ curl http://localhost:6636/api/stringReplace
$ curl http://localhost:6636/api/stringReplace

接口返回:

json
{
    "resultStr": "hello orapis"
}
{
    "resultStr": "hello orapis"
}

输入指定变量

参数输入:#{body.string},查找子串:#{body.child},替换为:#{body.rep}

img_29.png

使用curl请求接口:

$ curl http://localhost:6636/api/stringReplace -d "{ \"string\": \"this is abc\", \"child\": \"abc\", \"rep\": \"orapis\" }"
$ curl http://localhost:6636/api/stringReplace -d "{ \"string\": \"this is abc\", \"child\": \"abc\", \"rep\": \"orapis\" }"

接口返回:

json
{
    "resultStr": "this is orapis"
}
{
    "resultStr": "this is orapis"
}