slice
Returns a substring of 1 character beginning at the index specified by the argument passed in. An optional second argument specifies the length of the substring to be returned. String indices are numbered starting from 0.
Input
-
{{ 'Bonjour' | slice: 0 }}
Output
-
B
Input
-
{{ 'Bonjour' | slice: 2 }}
Output
-
n
Input
-
{{ 'Bonjour' | slice: 2, 5 }}
Output
-
njour
If the first parameter is a negative number, the indices are counted from the end of the string
Input
-
{{ 'Bonjour' | slice: -3, 2 }}
Output
-
ou