INR currency format

前端 未结 19 1784
栀梦
栀梦 2020-12-09 17:31

I need to show currency format like these, how can we show.

₹1
₹10
₹100
₹1,000
₹10,000
₹1,00,000
......
19条回答
  •  暖寄归人
    2020-12-09 18:02

    1. Get the digits before last three.
    2. Replace the rest of the digits with prefix.replace(/\B(?=(?:\d{2})+(?!\d))/g, ",")
    3. Combine the above section with this modified prefix

    Complete explanation on why this regex places commas at the right place is is mentioned here.

提交回复
热议问题