Created
May 9, 2019 23:46
-
-
Save jpcaparas/2821d4d677c6242c306ecd1f5a1299c4 to your computer and use it in GitHub Desktop.
JS: Sanitize amount
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
const sanitizeAmount = amount => { | |
return amount | |
.replace(/[^\d.]/g, '') // Remove non-numeric symbols | |
.replace(/\.(?!\d+$)/g, ''); // Remove excess "." symbols, and leave out the last "." | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment