Alternative for deprecated PHP function: eregi_replace [duplicate]

Solution 1:

preg_replace

https://php.net/preg-replace

$pattern = "/([a-z0-9][_a-z0-9.-]+@([0-9a-z][_0-9a-z-]+\.)+[a-z]{2,6})/i";
$replace = "<a href=\"mailto:\\1\">\\1</a>";
$text = preg_replace($pattern, $replace, $text);

Solution 2:

preg_replace