LoginSignup
24
26

More than 5 years have passed since last update.

Javascriptで数値の3桁区切りを実装

Last updated at Posted at 2013-05-21

10,000円とか、値段表記の際に使う数値の3桁区切りを行う関数。

function addFigure(str) {
    var num = new String(str).replace(/,/g, "");
    while(num != (num = num.replace(/^(-?\d+)(\d{3})/, "$1,$2")));
    return num;
}

参照
http://okadao.blogspot.jp/2009/10/javascript3.html

24
26
4

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
24
26