我有100000这样的数字
当我使用 number_to_currency(100000)
它给 - 100,000.00
但是我怎样才能得到像 1,00,000.00 这样的格式
100,000 美元看起来不错,但要以 Rs 显示,我需要像这样的分隔符 (',') - 1,00,00,000.00
最佳答案
结帐http://www.funonrails.com/2011/03/number-to-indian-currency-helper-for.html
def number_to_indian_currency(number, html=true)
txt = html ? content_tag(:span, 'Rs.', :class => :WebRupee) : 'Rs.'
"#{txt} #{number.to_s.gsub(/(\d+?)(?=(\d\d)+(\d)(?!\d))(\.\d+)?/, "\\1,")}"
end
关于ruby-on-rails - Rails Number 到印度货币格式转换助手,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4728469/