String mobile = “11111111111”;
log.error(“正则:{}”,mobile.replaceAll("(\d{3})\d{4}(\d{4})", “$1****$2”));//1111111 如果手机号不够11位,就不会脱敏
log.error(“截取:{}”,mobile.replace(mobile.substring(3, 7), ""));//********111
手机号脱敏问题
最新推荐文章于 2025-03-08 19:30:53 发布
String mobile = “11111111111”;
log.error(“正则:{}”,mobile.replaceAll("(\d{3})\d{4}(\d{4})", “$1****$2”));//1111111 如果手机号不够11位,就不会脱敏
log.error(“截取:{}”,mobile.replace(mobile.substring(3, 7), ""));//********111