JS方式实现隐藏手机号码中间4位数
1.截取
function test (value) { const start = value.slice(0, 3) const end = value.slice(-4) return `${start}****${end}` }
2.截取
function test(value){ const start = value.substring(0, 3) const end = value.substring(value.length-4) return `${start}****${end}` }
3.正则
function test(value){ var reg = /^(\d{3})\d{4}(\d{4})$/; return value.replace(reg, "$1****$2"); }
境随心转而悦,心随境转而烦