LoginSignup
4
5

More than 5 years have passed since last update.

カンマ付き数字かどうかチェックする正規表現

Last updated at Posted at 2016-05-25

指数とかには対応していませんが...。

サンプル

var reCommified = /^((?:[+\-]?0)|(?:[+\-]?[1-9][0-9]{0,2})(?:,\d{3})*)(?:\.(\d+))?$/;
var numString = "-123,456,789.1234";

var matched = numString.match(reCommified);

console.log(matched); //=> ["-123,456,789.1234", "-123,456,789", "1234", index: 0, input: "-123,456,789.1234"]
4
5
0

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
4
5