Format Number As Currency

Format Number As Currency
Add the commas that separate digits in large numbers using this FormatCurrency function for Ruby.
function FormatCurrency(NumToFormat)
{
        var Formatted;
        Formatted = NumToFormat.replace(/(^|[^\w.])(\d{4,})/g, function($0, $1, $2)
        {
                var Tmp;
                Tmp = $1 + $2.replace(/\d(?=(?:\d\d\d)+(?!\d))/g, "$&,");
                return Tmp;
        });
        return Formatted;
}

Leave a Reply

Your email address will not be published. Required fields are marked *

Back To Top