slice
Returns a substring of one character or series of array items beginning at the index specified by the first argument. An optional second argument specifies the length of the substring or number of array items to be returned.
String or array indices are numbered starting from 0.
Input
{{ "Liquid" | slice: 0 }}
Output
L
Input
{{ "Liquid" | slice: 2 }}
Output
q
Input
{{ "Liquid" | slice: 2, 5 }}
Output
quid
Here the input value is an array:
Input
{% assign beatles = "John, Paul, George, Ringo" | split: ", " %}
{{ beatles | slice: 1, 2 }}
Output
PaulGeorge
If the first argument is a negative number, the indices are counted from the end of the string.
Input
{{ "Liquid" | slice: -3, 2 }}
Output
ui