Page 1 of 1

[SOLVED]RegExp for {%download=[INSERT]%}

Posted: Mon Sep 06, 2004 12:38 pm
by vigge89
I've tried to create a regular expression which should replace the following:
{%download=img%}
into:
/p/dl/\\1={$res['id']}
{$res['id']} should be the contents of $res['id'] (right now set as 4 for example).
Here's what I currently have:

Code: Select all

<?php
$inc_out = preg_replace ("/\{%download=(.*)%\}/", "/p/dl/\\1={$res['id']}", $inc_out);
?>
but it doesn't work, i get this as the result:

Code: Select all

/p/dl/img%&#125;
it should result in:

Code: Select all

/p/dl/img=4
Thanks in advance

Posted: Mon Sep 06, 2004 1:25 pm
by feyd

Code: Select all

<?php
$inc_out = preg_replace ("/\{%download=(.*?)%\}/", "/p/dl/\\\\1={$res['id']}", $inc_out);
?>

Posted: Mon Sep 06, 2004 1:28 pm
by vigge89
I believe you forgot something ("/p/dl/\\1={$res['id']}")
but i tried the pattern out, and it seems to work, thanks :)

Posted: Mon Sep 06, 2004 1:31 pm
by feyd
that part got hidden when the highlighter went over it.