弃用PHP函数的替代方法:eregi_replace [英] Alternative for deprecated PHP function: eregi_replace

查看:1943
本文介绍了弃用PHP函数的替代方法:eregi_replace的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我需要这个sniplet:

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

谢谢!

解决方案

preg_replace



http://php.net/manual/fr/function.preg-replace.php

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


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

http://php.net/manual/fr/function.preg-replace.php

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

这篇关于弃用PHP函数的替代方法:eregi_replace的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆