The substr filter outputs a part of the supplied string, beginning at a particular character and optionally stopping after a certain length.

{{ "This is a string"|substr(3,6) }}
{# Returns "s is a" #}

You can also use a negative number for the first argument to start that number of characters from the end of the string.