Appearance
StringSub
返回字符串 s 中,索引 i 到索引 j 之间的子字符串。
当索引 i 在字符串 s 的位置在索引 j 的后面时,将返回一个空字符串。
Lua字符串的字节下标是从 1 开始的
业务属性
属性 | 含义 | 说明 | 输入限定 | 示例值 |
---|---|---|---|---|
enable | 是否启用该控件,未启用时不编译 | 是否编译 | 选择值 | 启用 |
name | 控件返回值命名 | 控件输出值变量名 | 常量 | subStr |
text | 与控件关联的文本 | 设计页控件显示 | 常量 | StringSub |
input | 输入字符串 | 常量 /流程变量 | #{str} | |
startIndex | 起始索引 | 常量 /流程变量 | 1 | |
endIndex | 截止索引 | 可选,为空时默认为input长度 | 常量 /流程变量 | 5 |
使用示例
输入常量
参数输入:hello world
,起始索引输入:7

输出控件返回resultStr
,data属性为:
json
{
"resultStr": "#{resultStr}"
}
{
"resultStr": "#{resultStr}"
}

使用curl请求接口:
$ curl http://localhost:6636/api/stringSub
$ curl http://localhost:6636/api/stringSub
接口返回:
json
{
"resultStr": "world"
}
{
"resultStr": "world"
}
输入指定变量
参数输入:#{body.string}
,查找子串:#{body.start}
,替换为:#{body.end}

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