经常使用正则表达式总结

前三位加逗号

export const formatMoney = (str) => {
    str = Number(str).toFixed(2);
    return str.replace(/\B(?=(\d{3})+($|\.))/g, ',');
};
相关文章
相关标签/搜索