ReqularExpression for currency format change


I need to format the value on keypress in the textbox.

I need to add comma(,) for every 3 digit from the last.

Currently I am having the regx like

z[0] = z[0].toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","); //result 1,200,0033

I am expecting "12,000,033"

It will be helpful anybody give the exact Regx