Interview icon indicating copy to clipboard operation
Interview copied to clipboard

第309题(2020-09-22):实现格式化输出,比如输入 999999999,输出 999,999,999?

Open qappleh opened this issue 5 years ago • 3 comments

qappleh avatar Sep 22 '20 02:09 qappleh

使用正则: var f = '99999999999'.replace(/\d{1,3}(?=(\d{3})+$)/g, '$&,');

qappleh avatar Oct 14 '20 03:10 qappleh

xiaoma-FrontEnd avatar Oct 30 '20 04:10 xiaoma-FrontEnd

'99999999999'.replace(/(?=(\d{3})+$)/g, '$&,') 这个也可以,前面的数字匹配是为了什么?

cuo9958 avatar Nov 05 '20 07:11 cuo9958