How can I convert
ereg_replace(".*\.(.*)$","\\1",$imgfile);
to
preg_replace... ?
?
I'm having trouble with it?
How can I convert
ereg_replace(".*\.(.*)$","\\1",$imgfile);
to
preg_replace... ?
?
I'm having trouble with it?
delimiters, add any char to beginning and end of expression, in this case, and by tradition, the '/' character preg_replace('/.*\.(.*)$/',"\\1",$imgfile);
The regex isn't very good, better to use strrpos and take substr().
Regex is slow, use this. $extension=substr($imgName,strrpos($imgName,'.'));
preg_replace("/.*\.(.*)$/", "\\1", "foo.jpg")
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.