<?php
$pattern = "/^([\w_]{2})(.+)([\w_]{2}@)/u";
$replacement = "$1********$3";
echo "Demonstração com \"preg_replace\"";
echo PHP_EOL;
for($i = 1; $i <= 20; $i++) {
echo PHP_EOL;
}
echo PHP_EOL.PHP_EOL;
echo "Demonstração com \"preg_replace_callback\"";
echo PHP_EOL;
function ocultarEmail($matches)
{
return $matches[1] .
$matches[3];
}
for($i = 1; $i <= 20; $i++) {
echo PHP_EOL;
}
PD9waHAKCiRwYXR0ZXJuICAgICA9ICIvXihbXHdfXXsyfSkoLispKFtcd19dezJ9QCkvdSI7CiRyZXBsYWNlbWVudCA9ICIkMSoqKioqKioqJDMiOwoKZWNobyAiRGVtb25zdHJhw6fDo28gY29tIFwicHJlZ19yZXBsYWNlXCIiOwplY2hvIFBIUF9FT0w7CmZvcigkaSA9IDE7ICRpIDw9IDIwOyAkaSsrKSB7CiAgICAkZW1haWwgPSBzdHJfcmVwZWF0KCJhIiwgJGkpLiJAdGVzdGUuY29tIjsKICAgIGVjaG8gcHJlZ19yZXBsYWNlKCRwYXR0ZXJuLCAkcmVwbGFjZW1lbnQsICRlbWFpbCk7CiAgICBlY2hvIFBIUF9FT0w7Cn0KCmVjaG8gUEhQX0VPTC5QSFBfRU9MOwplY2hvICJEZW1vbnN0cmHDp8OjbyBjb20gXCJwcmVnX3JlcGxhY2VfY2FsbGJhY2tcIiI7CmVjaG8gUEhQX0VPTDsKCmZ1bmN0aW9uIG9jdWx0YXJFbWFpbCgkbWF0Y2hlcykKewogICAgcmV0dXJuICRtYXRjaGVzWzFdIC4KICAgICAgICBzdHJfcmVwZWF0KCIqIiwgc3RybGVuKCRtYXRjaGVzWzJdKSkgLgogICAgICAgICRtYXRjaGVzWzNdOwp9Cgpmb3IoJGkgPSAxOyAkaSA8PSAyMDsgJGkrKykgewogICAgJGVtYWlsID0gc3RyX3JlcGVhdCgiYSIsICRpKS4iQHRlc3RlLmNvbSI7CiAgICBlY2hvIHByZWdfcmVwbGFjZV9jYWxsYmFjaygkcGF0dGVybiwgJ29jdWx0YXJFbWFpbCcsICRlbWFpbCk7CiAgICBlY2hvIFBIUF9FT0w7Cn0=