Given a filename in the form someletters_12345_moreleters.ext, I want to extract the 5 digits and put them into a variable.
someletters_12345_moreleters.ext
So to emphasize the point, I
Without any sub-processes you can:
shopt -s extglob front=${input%%_+([a-zA-Z]).*} digits=${front##+([a-zA-Z])_}
A very small variant of this will also work in ksh93.