Interview
Interview copied to clipboard
第309题(2020-09-22):实现格式化输出,比如输入 999999999,输出 999,999,999?
使用正则:
var f = '99999999999'.replace(/\d{1,3}(?=(\d{3})+$)/g, '$&,');
顶
'99999999999'.replace(/(?=(\d{3})+$)/g, '$&,') 这个也可以,前面的数字匹配是为了什么?