Skip to content

Instantly share code, notes, and snippets.

@daqi
Last active June 12, 2019 04:46
Show Gist options
  • Save daqi/2aeb0d8be0f58e4088cd73a844a4cebd to your computer and use it in GitHub Desktop.
Save daqi/2aeb0d8be0f58e4088cd73a844a4cebd to your computer and use it in GitHub Desktop.
FilterContactInfo
function FilterContactInfo($str){ // 过滤手机号码、QQ号、邮箱、地址
$str = preg_replace('/(Q|Q|扣扣|企鹅|扣|联系|手机|电话|号)+[:[:punct:]一二三四五六七八九零壹贰叁肆伍陆柒捌玖\d1234567890①②③⑤]+/i', '', $str);
// 过滤网址、邮箱
$str = preg_replace('/(网址|邮箱)*[\::]*[a-z]*\@?[a-z\-]+([\.\。][a-z]+)+/i', '', $str);
return $str;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment