1.String orgi = "010-5426321";
orgi = orgi.replaceAll("^(.{3})(.*)(.{4})$", "$1*****$3"); /* $1,$3是占位符,$1代表(.{3})也就是010. (.*)代表任意字符 $3代表 (.{4}) 也就是后四们6321*/
orgi = orgi.replaceAll("^(.{3})(.*)(.{4})$", "$1*****$3"); /* $1,$3是占位符,$1代表(.{3})也就是010. (.*)代表任意字符 $3代表 (.{4}) 也就是后四们6321*/
System.out.println(orgi);
2.String orgi = "15462348787";
orgi = orgi.replaceAll("(\\d{3})(\\d{5})(\\d{3})", "$1*****$3");
System.out.println(orgi);
好像是必须用“()”包起来才能用$1,$2,$3这样的占位符