实现效果:138****8888
var phone = '13888888888'; var resultPhone = phone.replace(/^(\d{3})\d{4}(\d+)/, '$1****$2'); console.log(resultPhone); // 138****8888