Skip to content

StringMatch

接收一个字符串及正则表达式,返回与正则表达式匹配的字符串。

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

业务属性

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

关于正则表达式的规则请自行查阅相关文档

使用示例

输入常量

参数输入:hello, 1234,正则表达式输入:\d+(匹配数字)

img_21.png

输出控件返回StringMatchdata属性为:

json
{
  "matchStr": "#{matchStr}"
}
{
  "matchStr": "#{matchStr}"
}
img_22.png

使用curl请求接口:

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

接口返回:

json
{
    "matchStr":"1234"
}
{
    "matchStr":"1234"
}

输入指定变量

参数输入:#{body.string},正则表达式输入:#{body.regex}

img_23.png

使用curl请求接口:

$ curl http://localhost:6636/api/stringMatch -d "{ \"string\": \"hello, 1234\", \"regex\": \"\\\\d+\" }"
$ curl http://localhost:6636/api/stringMatch -d "{ \"string\": \"hello, 1234\", \"regex\": \"\\\\d+\" }"

接口返回:

json
{
    "matchStr":"1234"
}
{
    "matchStr":"1234"
}