nth

Select positions from an array with nth-pattern syntax.

Syntax

{{ value | nth:3 }}{{ value | nth:2n }}{{ value | nth:n+3 }}{{ value | nth:2,3:4 }}

Example

01

Basic usage

InputTS
1{2  "items": [3    "a",4    "b",5    "c",6    "d",7    "e",8    "f"9  ]10}
TemplateKNAP
1{{ items | nth:2n }}
OutputKNAP
1["b","d","f"]

Behavior

  • Indexes are one-based. Patterns support a single position, every nth item, an offset, or positions within repeating groups.