80 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 6 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
80 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

Helpful Information

  • Please read our community guidelines. Self promotion and discussion of piracy is not allowed.
  • Open a support ticket if you would like specific help with your account, deposits or purchases.
  • Item Support by authors is optional and may vary. Please see the Support tab on each item page.

Most of all, enjoy your time here. Thank you for being a valued Envato community member.

Post Reply

Format your entry with some basic HTML. Read the Full Details, or here is a refresher:

<strong></strong> to make things bold
<em></em> to emphasize
<ul><li> or <ol><li> to make lists
<h3> or <h4> to make headings
<pre></pre> for code blocks
<code></code> for a few words of code
<a></a> for links
<img> to paste in an image (it'll need to be hosted somewhere else though)
<blockquote></blockquote> to quote somebody

:grin: :shocked: :cry: Complete List of Smiley Codes

by
by
by
by
by
by