Skip to content

stringSplit

根据指定的分隔符将一个字符串分割成多个子字符串,并将这些子字符串存储在一个数组中返回。

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

业务属性

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

使用示例

输入常量

input输入:a,b,cregex输入,

img_42.png

输出控件返回resultArrdata属性为:

json
{
  "resultArr": "#{resultArr}"
}
{
  "resultArr": "#{resultArr}"
}
img_43.png

使用curl请求接口:

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

接口返回:

json
{
    "resultArr": [
        "a",
        "b",
        "c"
    ]
}
{
    "resultArr": [
        "a",
        "b",
        "c"
    ]
}

输入指定变量

input输入:#{body.string}regex输入#{body.splitChar}

img_44.png

使用curl请求接口:

$ curl http://localhost:6636/api/stringSplit -d "{ \"string\": \"a,b,c\" ,\"splitChar\":\",\"}"
$ curl http://localhost:6636/api/stringSplit -d "{ \"string\": \"a,b,c\" ,\"splitChar\":\",\"}"

接口返回:

json
{
    "resultArr": [
        "a",
        "b",
        "c"
    ]
}
{
    "resultArr": [
        "a",
        "b",
        "c"
    ]
}