phone.replaceAll("(\\d{3})\\d{4}(\\d{4})","$1****$2");
152****4799

idCard.replaceAll("(\\d{4})\\d{10}(\\w{4})","$1*****$2");
4304*****7733

$1、$2、……表示正则表达式里面第一个、第二个、……括号里面的匹配内容

相关文章:

  • 2022-12-23
  • 2021-11-27
  • 2021-11-27
  • 2021-05-03
  • 2021-11-27
  • 2022-12-23
  • 2021-12-02
  • 2022-12-23
猜你喜欢
  • 2022-01-28
  • 2021-11-27
  • 2022-12-23
  • 2021-08-26
相关资源
相似解决方案