Skip to content

Segment: Array Element Searches

William W. Kimball, Jr., MBA, MSIS edited this page Mar 3, 2020 · 1 revision

YAML Path enables searching Arrays of scalar values, returning only those elements which match some criteria. For non-scalar searches, refer to (Hash Attribute Searches)[https://github.com/wwkimball/yamlpath/wiki/Segment:-Hash-Attribute-Searches], which are capable of searching more complex Arrays.

Along with the examples below, see Search Expressions for details of how to express Hash Attribute Searches.

Searching Arrays of Scalar Values

temperature:
  - 32
  - 0
  - 110
  - 100
  - 72
  - 68
  - 114
  - 34
  - 36

Should a user desire a report of all "triple-digit" recorded temperature measurements, they could use temperature[. =~ /\d{3}/] and they'd get back 3 results:

110
100
114
Clone this wiki locally