//utf8编码
header('content-type:text/html;charset=utf-8');
//去重,去点号,最后输出----我要好学习
$str="我我我....要要要....好好好...学学学学...习习习";
echo $str=preg_replace('/\.+/','',$str),'<br/>';
echo $str=preg_replace('/([\x{4e00}-\x{9fa5}])\\1+/u','${1}',$str);
echo "<hr/>";//分割线
//邮箱
$email='moyu31415926@sohu.com';
$reg="/[a-z0-9A-Z_-]+@[a-z0-9A-Z_-]+(\.[a-z]{2,5}){1,2}/";
$result=preg_match($reg,$email);
echo $result;
echo "<hr/>";//分割线
//手机
$phone=13686416678;
$reg="/^1[3-8][0-9]{9}$/";
$result=preg_match($reg,$phone);
echo $result;
echo "<hr/>";//分割线
//QQ号
$qq=1533861672;
$reg="/^[1-9][0-9]{4,10}$/";
$result=preg_match($reg,$qq);
echo $result;
echo "<hr/>";//分割线
//将192.168.1.1的ip转换为192.168.001.001
$ip='192.168.1.10 255.255.255.11 20.1.23.3';
$reg="/([0-9]+)/";
$ip=preg_replace($reg,'00$1',$ip);
$reg="/[0]{0,2}([0-9]{3})/";
$ip=preg_replace($reg,'$1',$ip);
$match=preg_split('/ +/',$ip);
foreach ($match as $value) {
echo $value,'<br/>';
}