Mark Hubbart <discordantus / gmail.com> writes:

>> Here's a direct Ruby translation:
>> 
>> def commify( number )
>>         text = number.to_s.reverse
>>         text.gsub!(/(\d\d\d)(?=\d)(?!\d*\.)/, '\1,')
>>         text.reverse
>> end
>
> golf?
>
> def commify(num)
>   num.to_s.reverse.scan(/..?.?/).join(",").reverse
> end
>
> ... sorry, couldn't resist. Weak character.

IMHO, that's even easier to read...

> cheers,
> Mark
>

-- 
Christian Neukirchen  <chneukirchen / gmail.com>  http://chneukirchen.org