ereg_replace到preg_replace? [英] ereg_replace to preg_replace?
本文介绍了ereg_replace到preg_replace?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我如何转换
ereg_replace(".*\.(.*)$","\\1",$imgfile);
到
preg_replace... ?
?
我有麻烦吗?
推荐答案
preg_replace("/.*\.(.*)$/", "\\1", "foo.jpg")
我不知道为什么PHP需要/
分隔符. Perl,JS等拥有它们的唯一原因是它们允许使用正则表达式文字,而PHP则不允许.
I don't know why PHP requires the /
delimiters. The only reason Perl, JS, etc. have them is that they allow regex literals, which PHP doesn't.
这篇关于ereg_replace到preg_replace?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文