//脱敏正则
//手机号脱敏
const phoneNumberReg = (phoneNumber: string) => {
return phoneNumber.replace(/(\d{3})\d{4}(\d{4})/, '$1****$2')
}
//车牌号脱敏
const licensePlateReg = (licensePlate: string) => {
return licensePlate.replace(/^(.\w{0,1})\w{1,4}(.)/, '$1****')
}
//清除所有空格
string.replace(/\s+/g, "")
各种各样的正则表达式(持续更新)
于 2024-03-15 09:29:56 首次发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)