Skip to content

Instantly share code, notes, and snippets.

@bmcminn
Created August 18, 2015 21:49
Show Gist options
  • Save bmcminn/34d1995ffb00aa4685e4 to your computer and use it in GitHub Desktop.
Save bmcminn/34d1995ffb00aa4685e4 to your computer and use it in GitHub Desktop.
My custom String object methods
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