A replacement callback is an option.
echo preg_replace_callback('/(?<=^.).+(?=@)/u', function($match) {
return str_pad('', strlen($match[0]), '*');
}, "something@something.com");
//s*******@something.com
Note I use an anonymous function as the callback - this is PHP >= 5.3 only. If you're on < 5.3, use a named function or one created with function_create()
.