I have a filename with several underscores: nc_glals_3_4.mrc and there I can read out the values 3 and 4 with awk:
$ echo "nc_glals_3_4.mrc" | awk -F\'[_.]\