📅  最后修改于: 2022-03-11 15:02:34.345000             🧑  作者: Mango
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"