'US $109.90/ea' should become '109.90'
Asked
Active
Viewed 34 times
-3
-
1Replace `[^\d.]+` with nothing. – ctwheels Nov 19 '19 at 23:46
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
- 62,450
- 9
- 45
- 52
-
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