主要分享php中手机号、座机、邮箱、身份证(15或18位)、手机号截取(中间四位为*)的正则表达式,都是自己工作收集而来,如果有不对的地方,欢迎提出,代码如下:
-
- $match = '/^((13[0-9])|(15[^4,\d])|(18[0,5-9]))[0-9]{8}$/';
-
- $match = '/^(0[0-9]{2,3}-)?([2-9][0-9]{6,7})+(-[0-9]{1,4})?$/';
-
- $match = '/(^d{15}$)|(^d{17}(d|X|x)$)/';
-
- $match = '/^w+([-+.]w+)*@w+([-.]w+)*.w+([-.]w+)*$/';
-
- $tel = 18600000000;
- $pattern = '/(d{3})d{4}(d{3})/';
- $replacement = "$1****$2";
- echo preg_replace($pattern,$replacement,$tel);
|