@@ -469,7 +469,7 @@ def evaluate_tuple_step(self, expr: parser.Parser.Symbol, input: Optional[Sequen
469469 result .tuple_stream = True
470470 step_env = environment
471471 if tuple_bindings is None :
472- tuple_bindings = [{"@" : item } for item in input if item is not None ]
472+ tuple_bindings = [{"@" : item } for item in input ]
473473
474474 for tuple_binding in tuple_bindings :
475475 step_env = self .create_frame_from_tuple (environment , tuple_binding )
@@ -519,7 +519,7 @@ def evaluate_filter(self, predicate: Optional[Any], input: Optional[Any], enviro
519519 if index < 0 :
520520 # count in from end of array
521521 index = len (input ) + index
522- item = input [index ] if index < len (input ) else None
522+ item = input [index ] if 0 <= index < len (input ) else None
523523 if item is not None :
524524 if isinstance (item , list ):
525525 results = item
@@ -684,9 +684,6 @@ def evaluate_wildcard(self, expr: Optional[parser.Parser.Symbol], input: Optiona
684684 if isinstance (value , list ):
685685 value = self .flatten (value , None )
686686 results = functions .Functions .append (results , value )
687- elif isinstance (value , dict ):
688- # Call recursively do decompose the map
689- results .extend (self .evaluate_wildcard (expr , value ))
690687 else :
691688 results .append (value )
692689
@@ -1475,7 +1472,14 @@ def apply_inner(self, proc: Optional[Any], args: Optional[Any], input: Optional[
14751472 elif isinstance (proc , Jsonata .JLambda ):
14761473 result = proc .call (input , validated_args )
14771474 elif isinstance (proc , re .Pattern ):
1478- result = [s for s in validated_args if proc .search (s ) is not None ]
1475+ _res = []
1476+ for s in validated_args :
1477+ if isinstance (s , str ):
1478+ _res .append (Jsonata ._regex_closure (proc .finditer (s )))
1479+ if len (_res ) == 1 :
1480+ result = _res [0 ]
1481+ else :
1482+ result = _res
14791483 else :
14801484 print ("Proc not found " + str (proc ))
14811485 raise jexception .JException ("T1006" , 0 )
@@ -1489,6 +1493,19 @@ def apply_inner(self, proc: Optional[Any], args: Optional[Any], input: Optional[
14891493 raise err
14901494 return result
14911495
1496+ @staticmethod
1497+ def _regex_closure (iterator ):
1498+ m = next (iterator , None )
1499+ if m is None :
1500+ return None
1501+ return {
1502+ "match" : m .group (),
1503+ "start" : m .start (),
1504+ "end" : m .end (),
1505+ "groups" : [m .group ()],
1506+ "next" : Jsonata .JLambda (lambda : Jsonata ._regex_closure (iterator ))
1507+ }
1508+
14921509 #
14931510 # Evaluate lambda against input data
14941511 # @param {Object} expr - JSONata expression
0 commit comments