This works:
var.replace(/[^0-9]+/g, \'\');
That simple snippet will replace anything that is not a number with nothing.
But decimals
there's a lot of correct answers already, just pointing out that you might need to account for negative signs too.. "\-" add that to any existing answer to allow for negative numbers.
"\-"