@@ -104,13 +104,15 @@ func RunConclude(concludeScript string, record libs.Record, sign *libs.Signature
104104 return otto.Value {}
105105 })
106106
107- // - RegexSelect("component", "var_name", " regex")
108- // - RegexSelect("component", "var_name", " regex")
107+ // - RegexSelect("component", "regex")
108+ // - RegexSelect("component", "regex")
109109 vm .Set ("RegexSelect" , func (call otto.FunctionCall ) otto.Value {
110- valueName , value := RegexSelect (record , call .ArgumentList )
111- if valueName != "" && value != "" {
112- utils .DebugF ("New variales: %v -- %v" , valueName , value )
113- sign .Target [valueName ] = value
110+ result := RegexSelect (record , call .ArgumentList )
111+ if len (result ) > 0 {
112+ for k , value := range result {
113+ utils .DebugF ("New variales: %v -- %v" , k , value )
114+ sign .Target [k ] = value
115+ }
114116 }
115117 return otto.Value {}
116118 })
@@ -147,37 +149,30 @@ func Between(value string, left string, right string) string {
147149}
148150
149151// RegexSelect get regex string from component
150- func RegexSelect (realRec libs.Record , arguments []otto.Value ) (string , string ) {
152+ func RegexSelect (realRec libs.Record , arguments []otto.Value ) map [string ]string {
153+ result := make (map [string ]string )
151154 // - RegexSelect("component", "var_name", "regex")
152155 utils .DebugF ("arguments -- %v" , arguments )
153- if len (arguments ) < 1 {
156+ if len (arguments ) < 2 {
154157 utils .DebugF ("Invalid Conclude" )
155- return "" , ""
158+ return result
156159 }
157160 componentName := arguments [0 ].String ()
158- valueName := arguments [1 ].String ()
159161 component := GetComponent (realRec , componentName )
160- regexString := arguments [2 ].String ()
162+ regexString := arguments [1 ].String ()
161163
162164 // map all selected
163165 var myExp = regexp .MustCompile (regexString )
164166 match := myExp .FindStringSubmatch (component )
165167 if len (match ) == 0 {
166168 utils .DebugF ("No match found: %v" , regexString )
167169 }
168- result := make (map [string ]string )
169170 for i , name := range myExp .SubexpNames () {
170171 if i != 0 && name != "" && len (match ) > i {
171172 result [name ] = match [i ]
172173 }
173174 }
174- utils .DebugF ("RegexMatchs: %v" , result )
175- value , exist := result [valueName ]
176- if ! exist {
177- return "" , ""
178- }
179- utils .DebugF ("RegexSelect: %v --> %v" , valueName , value )
180- return valueName , value
175+ return result
181176}
182177
183178// Execution Run a command
0 commit comments