var separator=(num)=>{ if(!num){ return '0.00'; }; let str = parseFloat(num).toFixed(2); return str && str .toString() .replace(/(d)(?=(d{3})+.)/g, function($0, $1) { return $1 + ","; }); } separator(386485473.99) //"386,485,473.99"
姓名加密
"慕容某霜"
.replace(/^(.+).(.)$/,
"$1*$2"
);
"李某平"
.replace(/^(.+).(.)$/,
"$1*$2"
);
电话号加密
'13947421022'.replace(/(d{3})d*([0-9]{4}/), "$1****$2");