-
-
Notifications
You must be signed in to change notification settings - Fork 23
Wildcard Segments
There are three types of wildcard segments:
- Match every immediate child.
- Match every leaf node.
- A convenience shorthand for Array Element Searches and Hash Attribute Searches.
This is identical to a Search segment where the search term is [.!=""]
. This translates to "match every Hash key for which its name is not empty and every Array element which is not empty". This operator also vertically expands results from Collectors, effectively breaking them out from an Array-per-line to one-Scalar-per-line. If you place this inside a Collector, the results will still be collected into an Array.
This new type is a "Traversal" segment which causes YAML Path operations to deeply traverse the document from that point. When there are no further segments in the YAML Path, every leaf node (Scalar value) is matched. When the YAML Path has at least one further segment, it (and all further segments) must match subsequent nodes (anywhere deeper than that point in the document) or none are matched. Results can be collected.
The * character now also serves as a wildcard character for key-names, Hash values, and Array value comparisons, converting the segment to a Search. For example, a YAML Path like abc.d*
becomes abc[.^d]
, abc.*f
becomes abc[.$f]
, and abc.*e*
becomes `abc[.=~/^.e.$/], and so on.