I am trying to get a replace method to format the string to something like:
100 000,10
If the value written was:
100j00 0,1 0
Always two decimals and for every three integers to insert a space(counting thousands). So far I have not managed that outcome.
const parse = (input) => {
const numberString = input ? input.toString().replace(/[^0-9]/g, '') : '';
return parseInt(numberString);
};
const NumberFormatFilter = () => {
return (input) => {
const number = parse(input);
return isNaN(number) ? '' :
number
.toLocaleString()
.replace(/\./g, ' ')
.replace(/,/g, ' ');
};
};
This will get me to a format x xxx(1 000) but I am having problems with making it into a format with x xxx,xx(1 000,20)