I’m using a GNU/Linux distribution where the utility rename comes from util-linux and I want to make full use of regular (Perl or POSIX) expression
rename
util-linux
The following command gives the expected result with your input file but using the perl version:
perl
rename 's/foo_\D+(\d+)/foo_$1/' *.ext
You can test the command using -n option to rename
-n