This works:
var.replace(/[^0-9]+/g, \'\');
That simple snippet will replace anything that is not a number with nothing.
But decimals
Try this:
var.replace(/[0-9]*\.?[0-9]+/g, '');
That only matches valid decimals (eg "1", "1.0", ".5", but not "1.0.22")