$ String = "13826589549 ";
$ Pattern = "/(\ D {3}) \ D (\ D {2 })/";
$ Replacement = "\ $1 ***** \ $3 ";
Print preg_replace ($ pattern, $ replacement, $ string );
Output result: 138 **** 9549
The matching result is what I want, but the matching mode is incorrect. It can only match 7 digits, and the remaining 4 digits cannot match, and \ $3 does not exist at all.
Which of the following statements is true?
$ String = "13826589549 ";
$ Pattern = "/(\ D {3}) \ D {4} (\ D {4 })/";
$ Replacement = "\ $1 ***** \ $2 ";
Print preg_replace ($ pattern, $ replacement, $ string );
You can also use the string truncation method to hide numbers in the middle.
Function suohao ($ phone ){
$ P = substr ($ phone,). "*****". substr ($ phone );
Return $ P;
}
Echo suohao ($ string );
Output: 138 **** 9549
The last number of hidden IP addresses is *
<? PHP echo preg_replace ("/[^ \.] {1, 3} $/", "*", $ IP);?>