17

有谁知道已弃用的 eregi_replace 函数的好选择?

我需要它来处理这个片段:

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

谢谢!

4

2 回答 2

25

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);
于 2010-01-18T09:12:45.983 回答
1

preg_replace

于 2010-01-18T09:12:46.670 回答