var tells = '手机号码' var tell = /(\d{3})\d*(\d{4})/; phone = tells.replace(tell, '$1****$2') console.log(phone);