Appearance
StringMatch
接收一个字符串及正则表达式,返回与正则表达式匹配的字符串。
Lua字符串的字节下标是从 1 开始的
业务属性
| 属性 | 含义 | 说明 | 输入限定 | 示例值 |
|---|---|---|---|---|
| enable | 是否启用该控件,未启用时不编译 | 是否编译 | 选择值 | 启用 |
| name | 控件返回值命名 | 控件输出值变量名 | 常量 | matchStr |
| text | 与控件关联的文本 | 设计页控件显示 | 常量 | StringMatch |
| input | 输入字符串 | 常量/流程变量 | #{str} | |
| regex | 正则表达式 | 常量/流程变量 | \d+ |
关于正则表达式的规则请自行查阅相关文档
使用示例
输入常量
参数输入:hello, 1234,正则表达式输入:\d+(匹配数字)

输出控件返回StringMatch,data属性为:
json
{
"matchStr": "#{matchStr}"
}{
"matchStr": "#{matchStr}"
}
使用curl请求接口:
$ curl http://localhost:6636/api/stringMatch$ curl http://localhost:6636/api/stringMatch接口返回:
json
{
"matchStr":"1234"
}{
"matchStr":"1234"
}输入指定变量
参数输入:#{body.string},正则表达式输入:#{body.regex}

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