Forum Moderators: coopster

Message Too Old, No Replies

preg replace

         

PeteM

7:50 pm on Nov 10, 2006 (gmt 0)

10+ Year Member



I need to add some characters to the middle of a URL. The change is to amend 'SCMZZZZZZZ_' to 'SCMZZZZZZZ_SL125_'.

E.g.

[ec1.images-mywebsite.com...]

Becomes.....

[ec1.images-mywebsite.com...]

I tried the following code:

$image = preg_replace('SCMZZZZZZZ_', 'SCMZZZZZZZ_SL125_', $image);

However this gave me an error message.....

Warning: preg_replace() [function.preg-replace]: Delimiter must not be alphanumeric or backslash in /homepages/17/d72034191/htdocs/aws/astore/amazon.php on line 328

I've checked the php.net manual and googled for a solution and have come to tht econclusion that fixing this on my own could easily consume a complete friday evening! Can anyone help?

Cheers, Pete

[edited by: PeteM at 7:51 pm (utc) on Nov. 10, 2006]

eelixduppy

7:59 pm on Nov 10, 2006 (gmt 0)



str_replace [us2.php.net] seems to be a better choice here:

$image = str_replace('SCMZZZZZZZ_', 'SCMZZZZZZZ_SL125_', $image);

For your pattern, you are lacking in an area:


$pattern = "/SCMZZZZZZZ_/";

However as I said, str_replace is a much better solution.

Good luck! :)

PeteM

8:11 pm on Nov 10, 2006 (gmt 0)

10+ Year Member



Job's a good'un (as we say)!

Cheers, Pete