82 posts
  • 3 Years of Membership
  • Austria
  • Collector Level 1
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
  • 6 Years of Membership
  • Affiliate Level 3
  • Author Level 3
  • Exclusive Author
+1 more
greenshady
says

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

#(http?://.+/.+)(\..+?)(.jpg|.png|.gif)$#i
82 posts
  • 3 Years of Membership
  • Austria
  • Collector Level 1
mattmatt88
says

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

Thanks a lot

by
by
by
by
by
by