Skip to content

Instantly share code, notes, and snippets.

@jhonsore
Last active September 20, 2019 14:09
Show Gist options
  • Select an option

  • Save jhonsore/f048b222aa0b723d648e8160e397235e to your computer and use it in GitHub Desktop.

Select an option

Save jhonsore/f048b222aa0b723d648e8160e397235e to your computer and use it in GitHub Desktop.
const strPtBrMoneyToNumber = value => {
if(!value){
console.warn('strPtBrMoneyToNumber needs a value to be converted');
return false;
}
value = String(value);
value = value.replace(/\./g, '#');//remove . e troca por #
value = value.replace(/,/g, '.');//remove a , e muda para .
value = value.replace(/#/g, '');//remove a # e muda para ""
return value;
}
console.log('1.000,99');
console.log(100);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment