Created
August 18, 2015 21:49
-
-
Save bmcminn/34d1995ffb00aa4685e4 to your computer and use it in GitHub Desktop.
My custom String object methods
This file contains hidden or 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 stripMoneyFormat(string, currency) { | |
currency = currency || '$'; | |
var regex = { | |
moneys: new RegExp('[\\'+currency+'\,]', 'g') | |
} | |
; | |
if (typeof(string) == "string") { | |
return parseFloat(string.replace(regex.moneys, ''))toFixed(2); | |
} else { | |
console.error(string + ' is not a string!!!'); | |
return null; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment