Skip to content

Wildcard Segments

William W. Kimball, Jr., MBA, MSIS edited this page Oct 11, 2020 · 18 revisions

There are three types of wildcard segments:

  1. Match every immediate child.
  2. Match every leaf node.
  3. A convenience shorthand for Array Element Searches and Hash Attribute Searches.

Match Every Immediate Child

This is a standalone * (single star) as a YAML Path segment. It looks like some.path.* or /some/path/*. More segments may follow it.

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.

Match Every Leaf Node

This is a standalone ** (double star) as a YAML Path segment. It looks like some.path.** or /some/path/**. More segments may follow it.

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.

Search Shorthand

The * character now also serves as a wildcard character for key-names, Hash values, and Array value comparisons, converting the segment to a Search Expression. 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.

Clone this wiki locally