I always have problems with regex, I basically have a url like this:
http://somedomain.com/something_here/bla/bla/bla/bla.jpg
I need preg_replace () to replace something_here an empty string and leave everything else in tact.
I tried the following and replace the wrong parts:
$image[0] = preg_replace('/http:\/\/(.*)\/(.*)\/wp-content\/uploads\/(.*)/','$2' . '',$image[0]);
The result is only the part that I want to replace, instead of replacing it!
source share