How To Add Commas To Numbers Without Rails Or ActiveSupport

Posted by Weston Ganger

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

Recommended Posts