mcya / JavaScriptExperience

👮 JavaScript Experience for web(JavaScript归类:简单入门+数组+经典循环+字符串+函数+Date日期+简单对象+BOM+DOM) +[ Issues(js实用技巧)]
29 stars 8 forks source link

手机号码*号替换 保留前三位和后两位 #23

Open mcya opened 6 years ago

mcya commented 6 years ago
13819019022.replace(/(\d{3})\d{6}(\d{2})/, '$1****$2')

==> 138******22
注:是十一位数  3+6+2==11  or  3+4+4==11(前三后四)