From 15886f68591425e3b3854b682b5bf46d558ccb3f Mon Sep 17 00:00:00 2001 From: Adrian Short Date: Mon, 14 Jun 2010 11:49:04 +0100 Subject: [PATCH] Improved commify() --- app.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app.rb b/app.rb index 66279de..8169206 100644 --- a/app.rb +++ b/app.rb @@ -6,7 +6,7 @@ require 'lib/models' helpers do def commify(amount) - amount.to_s.gsub(/(\d)(?=(\d{3})+$)/,'\1,') + amount.to_s.reverse.gsub(/(\d\d\d)(?=\d)(?!\d*\.)/,'\1,').reverse end end