Skip to content

StringSub

返回字符串 s 中,索引 i 到索引 j 之间的子字符串。

当索引 i 在字符串 s 的位置在索引 j 的后面时,将返回一个空字符串。

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

业务属性

属性含义说明输入限定示例值
enable是否启用该控件,未启用时不编译是否编译选择值启用
name控件返回值命名控件输出值变量名常量subStr
text与控件关联的文本设计页控件显示常量StringSub
input输入字符串常量/流程变量#{str}
startIndex起始索引常量/流程变量1
endIndex截止索引可选,为空时默认为input长度常量/流程变量5

使用示例

输入常量

参数输入:hello world,起始索引输入:7

img_33.png

输出控件返回resultStrdata属性为:

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

使用curl请求接口:

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

接口返回:

json
{
    "resultStr": "world"
}
{
    "resultStr": "world"
}

输入指定变量

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

img_35.png

使用curl请求接口:

$ curl http://localhost:6636/api/stringSub -d "{ \"string\": \"hello world\", \"start\": 1, \"end\": 5 }"
$ curl http://localhost:6636/api/stringSub -d "{ \"string\": \"hello world\", \"start\": 1, \"end\": 5 }"

接口返回:

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