I'm using this simple code:
$raw = 'text hi@li.com text';
$raw = preg_replace('<[\w.]+@[\w.]+>', '***@$2', $raw);
And i should get as output, something like ***@li.com
; while i get ***@
I can't debug it, i don't know how what's wrong.
So the solution is
preg_replace('<([\w.]+)@([\w.]+)>', '***@$2', $raw);
I had to add () to make a group.