📌  相关文章
📜  javascript 格式的社会保险号 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:02:34.345000             🧑  作者: Mango

代码示例1
function formatSocialSecurity(val){
    val = val.replace(/\D/g, '');
    val = val.replace(/^(\d{3})/, '$1-');
    val = val.replace(/-(\d{2})/, '-$1-');
    val = val.replace(/(\d)-(\d{4}).*/, '$1-$2');
    return val;
}          
formatSocialSecurity("135711458");//"135-71-1458"