使用正则表达式可以非常方便的进行复杂的字符串的替换
例如常见需求 , 把手机号12323432342 中间四位换成*
$telphone=preg_replace("/(d{3})(d+)(d{4})/",'$1****$3',"12323422342");
把IP地址后面两位换成* 124.207.122.98
$ip=preg_replace("/(d+.d+).(d+).(d+)/",'$1.*.*',$ip);