The 4 digits in the java mobile phone number become , desensitized

Effect:

Code:

String phone = "13100001111";
String phoneResult = phone.replaceAll("(\\d{3})\\d{4}(\\d{4})","$1****$2");
System.out.println(phoneResult);

result:

ps: Don’t talk about front-end processing. In order to keep the data confidential, since it needs to be processed, the unmasked data cannot be sent to the front end.

Leave a Comment

Your email address will not be published. Required fields are marked *