You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
;; A slice expression allows you to select a subset of an array. A slice has a start, stop, and step value. The
256
-
;; general form of a slice is [start:stop:step], but each component is optional and can be omitted.
256
+
;; A slice expression allows you to select a subset of an array or a string. A slice has a `start`, `stop`, and `step` value. The
257
+
;; general form of a slice is `[start:stop:step]`, but each component is optional and can be omitted.
257
258
;;
258
259
;; ```note
259
260
;; Slices in JMESPath have the same semantics as python slices. If you're familiar with python slices, you're familiar with
260
261
;; JMESPath slices.
261
262
;; ```
262
263
;;
263
-
;; Given a start, stop, and step value, the sub elements in an array are extracted as follows:
264
+
;; Given a `start`, `stop`, and `step` value, the sub elements in an array or characters in a string are extracted as follows:
264
265
;;
265
-
;; - The first element in the extracted array is the index denoted by start.
266
-
;; - The last element in the extracted array is the index denoted by end - 1.
267
-
;; - The step value determines how many indices to skip after each element is selected from the array.
268
-
;; The default step value of 1 will not skip any indices and will return a contiguous subset of the original array.
269
-
;; A step value greater than 1 will skip indices while extracting elements from an array. For instance, a step value of 2 will
270
-
;; skip every other index.
271
-
;; Negative step values start from the end of the array and extract elements in reverse order.
266
+
;; - The first element in the extracted array or first character in the extracted string is the index denoted by `start`.
267
+
;; - The last element in the extracted array or last character in the extracted string is the index denoted by `end - 1`.
268
+
;; - The `step` value determines how many indices to skip after each element is selected from the array or each character is selected from the string.
269
+
;; The default `step` value of `1` will not skip any indices and will return a contiguous subset of the original array or a substring of the original string.
270
+
;; A `step` value greater than `1` will skip indices while extracting elements from an array or characters from a string. For instance, a `step` value of `2` will
271
+
;; skip every other element or character.
272
+
;; Negative `step` values start from the end of the array or string and extract elements or characters in reverse order.
272
273
;;
273
274
;; Slice expressions adhere to the following rules:
274
275
;;
275
-
;; - If a negative start position is given, it is calculated as the total length of the array plus the given start position.
276
-
;; - If no start position is given, it is assumed to be 0 if the given step is greater than 0 or the end of the array if
277
-
;; the given step is less than 0.
278
-
;; - If a negative stop position is given, it is calculated as the total length of the array plus the given stop position.
279
-
;; - If no stop position is given, it is assumed to be the length of the array if the given step is greater than 0 or 0 if
280
-
;; the given step is less than 0.
281
-
;; - If the given step is omitted, it it assumed to be 1.
282
-
;; - If the given step is 0, an error MUST be raised.
283
-
;; - If the element being sliced is not an array, the result is null.
284
-
;; - If the element being sliced is an array and yields no results, the result MUST be an empty array.
276
+
;; - If a negative `start` position is given, it is calculated as the total length of the array or string plus the given `start` position.
277
+
;; - If no `start` position is given, it is assumed to be `0` if the given `step` is greater than 0 or the end of the array or string if
278
+
;; the given `step` is less than `0`.
279
+
;; - If a negative `stop` position is given, it is calculated as the total length of the array or string plus the given `stop` position.
280
+
;; - If no `stop` position is given, it is assumed to be the length of the array or string if the given `step` is greater than `0` or `0` if
281
+
;; the given `step` is less than `0`.
282
+
;; - If the given `step` is omitted, it it assumed to be `1`.
283
+
;; - If the given `step` is `0`, an error MUST be raised.
284
+
;; - If the element being sliced is not an array or a string, the result is `null`.
285
+
;; - If the element being sliced is an array or string and yields no results, the result MUST be an empty array.
0 commit comments