var s = "-12345.50 €".replace(/[^\d.-]/g, ''); // gives "-12345.50"
Here is what the above code is Doing:
1. The first part of the regex, [^\d.-] , matches any character that is not a digit, a period, or a hyphen.
2. The g flag tells the regex engine to replace all matches, not just the first one.
3. The second argument to replace() is the replacement string. In this case, it’s the empty string, which means that the matched characters will be removed.