Created
April 8, 2020 14:25
-
-
Save smokinggoats/070240450631c839f36dbdf15c995771 to your computer and use it in GitHub Desktop.
Format any string to a simple number
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function toNumber(num) { | |
return Number(String(num).replace(/\./g, ',').replace(/(.+),/g, '$1.').replace(/[^\d.]/g, '').trim()) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment