spamalam Posted July 23, 2006 Share Posted July 23, 2006 I always seem to have trouble making regular expression strings. Basically amazon have changed their site design and now there affiliates pictures have this white matting. The thing is, amazon have the original images you just need to change the url a tiny bitEssentially to remove the matting from:http://images.amazon.com/images/P/B00005LQ0Z[b].01._SS500_SC[/b]LZZZZZZZ[b]_V1124758743_[/b].jpgyou just have to change the url tohttp://images.amazon.com/images/P/B00005LQ0Z[b].02.[/b]LZZZZZZZ.jpgeg:http://images.amazon.com/images/P/B00005LQ0Z.01._SS500_SCLZZZZZZZ_V1124758743_.jpghttp://images.amazon.com/images/P/B00005LQ0Z.02.LZZZZZZZ.jpgNow i'm having difficulty doing a regex that works, I figure something like this would do it:$ret = preg_replace("[/]images[/]P[/](.*)(\.01\._SS500_SC)(LZZZZZZZ)(_V[0-9]*_)(\.jpg)","[/]images[/]P[/]\\1\.02\.\\3\\5", $ret);But it complains. Can't seem to wrap my head round the regex.Thanks for the no doubt simple correctionps. hope i posted in the right place Quote Link to comment Share on other sites More sharing options...
ToonMariner Posted July 28, 2006 Share Posted July 28, 2006 Now not wanting to disappoint BUT is the only difference that '01' changes to '02' and '_SS500_SC' and '_V1124758743_'?basically you need to match patterns.If the above were true then something like....$lookfor = array('/\.01\._SS500_SC/' , '/_V(.)*_/');$replace = array('.02.' , '');$new = preg_replace( $lookfor, $replace ,$old);see if that fits the bill. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.