Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/264.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php eregi_替换到preg_替换转换_Php_Regex - Fatal编程技术网

Php eregi_替换到preg_替换转换

Php eregi_替换到preg_替换转换,php,regex,Php,Regex,我已经升级了我的php,现在我收到了eregi_替换的警告消息 你能帮我把下面的ereg表达式转换成preg吗 $str = eregi_replace("[[:space:]]+", " ", $str); $text = eregi_replace('<a href=?([^ "\']*)>([^<]*)</a>', '<a href="\\1">\\2</a>', $text); $text = eregi_replace('<a

我已经升级了我的php,现在我收到了eregi_替换的警告消息

你能帮我把下面的ereg表达式转换成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);
$str=eregi_replace(“[[:space:]+”,“”,$str);
$text=eregi_替换(“”,$text);
$text=eregi_替换(“”,$text);
$text=eregi_replace('([[:space:]()[{}])(www.[-a-zA-Z0-9@:%\+.~#?&/=]+),'\\1',$text);
$text=eregi_replace('([[u\.0-9a-z-]+@[0-9a-z][0-9a-z-]+\)+[a-z]{2,3}',$text);

谢谢

转换非常简单。他们有一个差异列表/解释


您将看到的最大(可能是唯一)更改是在模式字符串中添加分隔符。

我这样做了,但收到错误警告:preg_replace()[function.preg replace]:未知修饰符“?”。([[:space::()[{}])(www.[-a-zA-Z0-9@:%\+.~#?&/=])#i@jason4,您正在使用#作为分隔符,也在模式中使用。请选择另一个分隔符或在模式内转义
\\\code>哈希标记。