ereg_replace, preg_replace and PHP 5.3.0 [duplicate]

我只是一个虾纸丫 提交于 2020-01-06 05:39:06

问题


Possible Duplicates:
Changing ereg_replace to equivalent preg_replace
Converting ereg expressions to preg

Can anyone show me the equivalent of :

ereg_replace("\n#[^\n]*\n", "\n", $sql)

in preg_replace

Thanks


回答1:


All you need in this case is delimiters (here /):

preg_replace("/\n#[^\n]*\n/", "\n", $sql)

Also read about the difference of PCRE from POSIX.




回答2:


preg_replace("~\n#[^\n]*\n~", "\n", $sql);


来源:https://stackoverflow.com/questions/6269616/ereg-replace-preg-replace-and-php-5-3-0

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!