'US $109.90/ea' should become '109.90'
Asked
Active
Viewed 58 times
1 Answers
1
You can replace all characters except number and dot with empty string:
var str = 'US $109.90/ea';
var number = str.replace(/[^\d.]+/g, '');
console.log(number);

Mamun
- 66,969
- 9
- 47
- 59
-
1No alternation needed. Add `+` quantifier to make it more efficient (like I have in my comment below the question) – ctwheels Nov 20 '19 at 00:02