Heres a quick technique to add commas to a numbers in Ruby when you don’t have access to Rails or ActiveSupport
num = 123456789
num.to_s.reverse.gsub(/(\d{3})(?=\d)/, '\\1,').reverse
Related External Links:
Heres a quick technique to add commas to a numbers in Ruby when you don’t have access to Rails or ActiveSupport
num = 123456789
num.to_s.reverse.gsub(/(\d{3})(?=\d)/, '\\1,').reverse
Related External Links:
Article Topic:Software Development - Rails
Date:February 28, 2017
Want me to help develop your next Ruby-on-Rails project or application?
Contact Me