HOw can we replace aplnumeric value to numeric in JavaaScript

var test='A1' then its output should be 00001 and var test='A1B20' then its output should be 00120

input Output
A1 00001
A12 00012
A12345 12345
A12B34 01234
A1B25 00125