Format BRL Currency
Remove dots and commas from string with javascript
by Gabriel Correa
JavaScript
// Sample Data
var value = '1.000,00';
var arr = ['1,00',
'10,00',
'500,00',
'5.000,00',
'70.000,00',
'900.000,00',
'1.000.000,00']
// Remove cents
alert(value.split(',')[0]);
// Remove . and cents
console.log(Number(value.split(',')[0].replace(/[^0-9]+/g,"")));
arr.map(value => console.log(Number(value.split(',')[0].replace(/[^0-9]+/g,""))))
// Remove . and replace , to .
arr = arr.map(v => v.replace(/\./g, "").replace(",", "."));
console.log(arr);