tags:

views:

29

answers:

1

Hi,

I'm trying to write a regular expression to modify URLs stored in a database (linking to photos on Flickr) so I can change the size of photos already on a site -

E.g. Replace: 4724575242_ca7d120609.jpg with 4724575242_ca7d120609_z.jpg in a URL such as:

http://farm2.static.flickr.com/1045/4724575242_ca7d120609.jpg

The only change is to add _z before the .jpg extension.

I imagined that a regular expression could be written which matches static.flickr.com then replace .jpg with _z.jpg but unfortunately my attempts have so far failed.

I wondered if any regex ninjas out there might be able to help me with this?

Any help would be greatly appreciated - David

+1  A: 

Maybe this one (adapting it to your language, of course) ?

/static\.flickr\.com\/([a-z0-9_\/]+)\.jpg$/static.flickr.com\/$1_z.jpg/
Pikrass
Thanks so much! Using the wordpress Search Regex plugin I used the search pattern:/static\.flickr\.com\/([a-z0-9_\/]+)\.jpg/and replace pattern:static.flickr.com/$1_z.jpg
David