mardi 5 mai 2020

How to parse number with points and commas

I recieve an string like;

1.234.567,89

I want 1234567.89

Comma is decimal delimiter.Point is thousands, and millions delimiter

I want to treat as a number.

I try replaces, but only works with first ".". And parseFloat. Also I try some regex that found here,but doesn't work for me

I want this;

    var numberAsString= '1.234.567,89';
    //Step to clean string and conver to a number to compare (numberAsString => numberCleaned)
    if (numberCleaned> 1000000) {alert("greater than 1 million");}

Any Idea? (Sorry if its a newbie question, but I dont found any solution in hours...)




Aucun commentaire:

Enregistrer un commentaire