Products
GG网络技术分享 2025-03-18 16:14 4
例如:有个列是“15812345678,13112345678”,需要用正则表达式将值变成“158####5678,131####5678”,可以用正则表达式写出来了吗?因为用的自写的一个框架,有点垃圾,不能分割或者根据下标拼接什么的,目前只能用正则表达式
function mobileNumberChange = (str) => {return str.replace(/(\\d{3})\\d*(\\d{4})/, '$1****$2');
};
```javascript
const telFormat = (tel) => {
tel = String(tel);
return tel.substr(0,3) + "****" + tel.substr(7);
};
```
直接切不就完了
数字类的匹配用穷举比较简单一点,直接排列想要的数字,以7为例:
Demand feedback