67 posts
  • Has been part of the Envato Community for over 2 years
  • Has collected 1+ items on Envato Market
mattmatt88 says

Hello

I’ve got lot of different image URLs like these

http://mypage.co.uk/images/2012/4123hu480._BO2,204,203,200.jpg
http://mypage.com/fav9hu3.9033,210,200.jpg

I need to change them (I think with preg_replace), so that the content between the last two dots disappears.

So the links should be:

http://mypage.co.uk/images/2012/4123hu480.jpg
http://mypage.com/fav9hu3.jpg

Note that there might be other dots in the URL. Only the content between the last two dots should be cleared.

Can you help me with that?

158 posts
  • Has been part of the Envato Community for over 5 years
  • Has referred 50+ members
  • Has sold $1,000+ on Envato Market
  • Sells items exclusively on Envato Market
+1 more
greenshady says

I’m thinking you’d need a pattern along these lines (completely untested):

#(http?://.+/.+)(\..+?)(.jpg|.png|.gif)$#i
67 posts
  • Has been part of the Envato Community for over 2 years
  • Has collected 1+ items on Envato Market
mattmatt88 says

That worked very well. Although I will never understand these kind of codes ^^

Thanks a lot

by
by
by
by
by
by