开发者

eregi_replace to preg_replace conversion

I have upgraded my php now i am getting warning messages for eregi_replace

Can you please help me in converting following ereg expression to preg?

$str = eregi_replace("[[:space:]]+", " ", $str);
$text = eregi_replace('<a href=?([^ "\']*)>([^<]*)</a>', '<a href="\\1">\\2</a>', $text);
$text = eregi_replace('<a href=(\')?([^ "\']*)(\')>([^<]*)</a>', '<a href="\\2">\\4</a>', $text);
$text = eregi_replace('([[:space:]()[{}])(www.[-a-zA-Z0-9@:%_\+.~#?&//=]+)',  '\\1<a href="http://\\2"开发者_开发知识库 target="_blank">\\2</a>', $text);
$text = eregi_replace('([_\.0-9a-z-]+@([0-9a-z][0-9a-z-]+\.)+[a-z]{2,3})', '<a href="mailto:\\1" target="_blank">\\1</a>', $text);

Thanks


The conversion is pretty straight forward. They have a list / explanation of diffrerences here

The biggest (only, maybe) change you are going to see is the addition of delimiters to the pattern strings.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜