Skip to content

Bars Specification 0.1.0 — Transform: slice

Category: string · Since: 0.1.0

Extracts a character or substring by offset.

With one argument, returns the single character at offset; with two arguments, returns length characters starting at offset. A negative offset counts from the end of the input. Offsets fully outside the string yield "". length is clamped to the remaining input; a negative length is a degenerate-value soft failure.

Input coercion: string

Arguments

Name Type Optional Default
offset integer no
length integer yes

Arity: 1–2

Worked examples

{{ phrase | slice: 1 }}

e
{{ phrase | slice: 1 3 }}

ell

Full fixture: transforms/transform-slice.json