What happens in the following cases:
123min456
1min
max2
minmax
1m2a3x4
?
How about doing it in two steps: 1) check to see if the string matches "min" or "max", 2) if it doesn't, replace all non-digits:
var text = "123ef456d";
if(!text.match(/^(?:min|max)$/gi)) {
text = text.replace(/[^\d]/gi, '');
}