开发者

Alternative for deprecated PHP function: eregi_replace [duplicate]

This question already has answers here: How can I convert ereg expressions to preg in PHP? (4 answers) 开发者_StackOverflow Closed 3 years ago.

Do anyone know a good alternative for the deprecated eregi_replace function?

I need it for this sniplet:

$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);

Thanks!


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);


preg_replace

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜