亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

javascript - Regular expression /(\d)(?=(\d{3})+\.)/g
伊謝爾倫
伊謝爾倫 2017-05-19 10:35:23
0
1
805

How to add a comma to every three digits of the number to the left of a floating point number, such as converting 12000000.11 into "12,000,000.11"?

function commafy(num){

  return num && num
      .toString()
      .replace(/(\d)(?=(\d{3})+\.)/g, function(, ){
          return  + ',';
      });

}
I don’t know how to understand this regular rule. /(d)(?=(d{3}) .)/g
Not sure how it works

伊謝爾倫
伊謝爾倫

小伙看你根骨奇佳,潛力無限,來學(xué)PHP伐。

reply all(1)
阿神

Match/(d)(?=(d{3})+.)/gThe number is followed by three digits or a multiple of 3, followed by a decimal point. d{3})+ means a number that is a multiple of 3, such as 3 numbers, 6 numbers, etc., ?= means that the following number must be a multiple of 3

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template