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
Building on jor's answer (which doesn't work for me):
substring=$(expr "$filename" : '.*_\([^_]*\)_.*')