有谁知道可以从 php 中使用的一个好的解决方案,它可以有效地从文档中删除联系信息,如电话号码、电子邮件地址,甚至可能是联系地址?
更新
嘿伙计们,这是我到目前为止想出的,效果很好。
function sanitizeContent($content)
{
// emails - even containing white space characters like this 't e s t @ ba d . co m'
$content = preg_replace('/([A-Za-x-0-9\s\_\.]{1,50})(?=@)@([A-Za-x-0-9\s\_\.]{1,50})/', '[email removed]', $content);
// urls
$content = preg_replace('/[a-zA-Z]*[:\/\/]*[A-Za-z0-9\-_]+\.+[A-Za-z0-9\.\/%&=\?\-_]+/i', '[link removed]', $content);
// phone numbers
$content = preg_replace('/(\d)?(\s|-|.|\/)?(\()?(\d){3}(\))?(\s|-|.|\/){1}(\d){3}(\s|-|.|\/){1}(\d){4}/', '[phone removed]', $content);
$content = preg_replace('/[0-9\.\-\s\,\/(x|ext)]{5,50}/', '[phone removed]', $content);
// addresses????
return $content;
}
有没有人对地址有任何想法,我想可能想出一种方法来检测城市,州邮编,然后在此之前删除 x 字符。它可能会意外破坏一些数据,但这可能比披露更好。我真的很想知道是否有其他人遇到过这个问题。