From 0170dc3cd783ad49cfb8dc290fd2d904b36397dd Mon Sep 17 00:00:00 2001 From: Robin Martijn Date: Wed, 28 Jun 2023 14:29:30 +0200 Subject: [PATCH] add extra example to slice filter --- doc/filters/slice.rst | 3 +++ 1 file changed, 3 insertions(+) diff --git a/doc/filters/slice.rst b/doc/filters/slice.rst index ae83b57a0..eb43d9946 100644 --- a/doc/filters/slice.rst +++ b/doc/filters/slice.rst @@ -37,6 +37,9 @@ As syntactic sugar, you can also use the ``[]`` notation: {# you can omit the last argument -- which will select everything till the end #} {{ '12345'[2:] }} {# will display "345" #} + {# you can use a negative value -- for example to remove characters at the end #} + {{ '12345'[:-2] }} {# will display "123" #} + The ``slice`` filter works as the `array_slice`_ PHP function for arrays and `mb_substr`_ for strings with a fallback to `substr`_.