On Tuesday 05 August 2003 16:55, Chris Morris wrote:
> I'm brain dead and just trying to get formatted numbers in a task
> that's already 10 tangents deep -- argh. Anyway, how can I sprintf
> (or otherwise) this:
>
>   456778904
>
> to this:
>
>   456,778,904

Yet another regex solution:

    % ruby -e 'puts "456778904".gsub(/(.)(?=.{3}+$)/, %q(\1,))'
    456,778,904

-- fxn

    .gsub(/(\d)(?=\d{3}+$)/, '\1,')