Get a substring in POSIX sh
POSIX sh has no ${v:2:3}. Build a substring from two prefix strips instead, or use cut when a subprocess is acceptable. Both run in dash.
Bash gives you ${v:2:3}, but under #!/bin/sh on Debian the same line is a syntax error.
v=abcdefgh
echo "${v:2:3}"main.sh: 2: Bad substitutionv=abcdefgh
rest=${v#??}
echo "${rest%"${rest#???}"}"
printf '%s\n' "$v" | cut -c3-5cde
cdeThe first run shows dash rejecting the offset syntax. The second works only with operators that are in POSIX parameter expansion: ${v#??} drops the first two characters, ${rest#???} leaves everything after the first three, and removing that from the end of rest leaves exactly three characters. cut -c is the simpler spelling when a fork is fine.
The pure expansion version is hard to read, so wrap it in a function with a comment. GNU cut -c counts bytes, not characters, so multibyte text can be cut in the middle of a character.