/* Add commas to a number with the ability to define : s_Decimal = The decimal separator in the output string - Default is English '.' s_Thousand = The separator for every 3 digits - Default is English ',' s_SplitDecimalUsing = If you are formatting an English input to non-English output, you can use a different decimal separator for your input and your output - Default is English '.' */ addCommas : function(s_Decimal, s_Thousand, s_SplitDecimalUsing) { s_Decimal = (arguments.length < 1) ? '.' : s_Decimal; s_Thousand = (arguments.length < 2) ? ',' : s_Thousand; s_SplitDecimalUsing = (arguments.length < 3) ? '.' : s_SplitDecimalUsing;
var a_Parts = this.lTrim('0').split(s_SplitDecimalUsing); a_Parts[2] = a_Parts.length > 1 ? s_Decimal + a_Parts[1] : ''; a_Parts[0] = (0 == a_Parts[0].length) ? '0' : a_Parts[0]; var obj_RegEx = /(\d+)(\d{3})/; while (obj_RegEx.test(a_Parts[0])) { a_Parts[0] = a_Parts[0].replace(obj_RegEx, '$1' + s_Thousand + '$2'); } return a_Parts[0] + a_Parts[2]; }, --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Prototype: Core" group. To post to this group, send email to prototype-core@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/prototype-core?hl=en -~----------~----~----~----~------~----~------~--~---