'Remove all letters from a variable except the period?
I am doing some webscraping and trying to filter this variable.
var oldtext = $0.00Amount
var newtext= text.replace(/\D/g, "");
This results in '000' and I need to keep the period.
I know I could write a replace function for each $, A, M, O, U, N, T but is there a smarter way to do that?
Solution 1:[1]
it covers negative values also.
console.log("Price is 1.223$".replace(/[^\d.-]/g, ''));
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | nagendra nag |
