Skip to content

Instantly share code, notes, and snippets.

@ipmsteven
Created September 4, 2014 08:03
Show Gist options
  • Select an option

  • Save ipmsteven/099b8a4b0b0d90fd4446 to your computer and use it in GitHub Desktop.

Select an option

Save ipmsteven/099b8a4b0b0d90fd4446 to your computer and use it in GitHub Desktop.
another ruby regular expression based solution for format_currency
def format_currency(number)
return number if number.blank?
("%.2f" % number).reverse.gsub(/(\d{3})(?=\d)/, '\\1,').reverse
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment