Appearance
StringReplace
将目标字符串 s 中所有的子串 p 替换成字符串 r。
Lua字符串的字节下标是从 1 开始的
业务属性
| 属性 | 含义 | 说明 | 输入限定 | 示例值 |
|---|---|---|---|---|
| enable | 是否启用该控件,未启用时不编译 | 是否编译 | 选择值 | 启用 |
| name | 控件返回值命名 | 控件输出值变量名 | 常量 | repStr |
| text | 与控件关联的文本 | 设计页控件显示 | 常量 | StringRep |
| input | 输入字符串 | 常量/流程变量 | #{str} | |
| childString | 字符串子串 | 常量/流程变量 | abc | |
| replacement | 替换字符串 | 常量/流程变量 | #{rStr} |
使用示例
输入常量
参数输入:hello world,查找子串:world,替换为orapis

输出控件返回resultStr,data属性为:
json
{
"resultStr": "#{resultStr}"
}{
"resultStr": "#{resultStr}"
}
使用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}

使用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"
}