Replace in a string with regex
| From: | rszeus | Date: | Wed, 22 Jul 2009 12:02:23 +0000 |
| Subject: | Replace in a string with regex | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-295664@lists.php.net to get a copy of this message | ||
Hello,
Im tryng to make some replacements on a string.
Everything goês fine until the regular expression.
$file = "screens/temp/7a45gfdi6icpan1jtb1j99o925_1_main.jpg";
echo $a = str_replace(array(7a45gfdi6icpan1jtb1j99o925,
'temp/',_([0-9])), array(test,"",), $file)
The idea is to remove /temp and the last _1 from the file name..but im only
getting this:
screens/test_1_main.jpg
I want it to be: screens/test_main.jpg
Thank you