JS代码:
方法 ① :字符串截取+拼接
(phone) { ( phone ) { phonephone.(); } phone.(,) phone.(,); }
functionformatPhoneiftypeof==‘number‘=
=toString
toStringreturnsubstr03+‘*
*
*
*
‘****+substr711
方法 ②:正则表达式替换
(phone) { phone.(,); } functionformatPhonereturnreplace/(\d{3
})\d{4
}(\d{4
})/344"$
1
*
*
*
*
$
2
"$1****$2