[pmwiki-devel] $12.50 -> .50 var problem

Jason Frisvold xenophage0 at gmail.com
Mon Apr 9 19:46:34 CDT 2007


On 4/9/07, The Editor <editor at fast.st> wrote:
> Thanks Christian, I did try that early on, with no luck--in fact that
> was my initial code.  Can't really understand why it is doing what it
> is...

In PHP 4.0.4+, backreferences are of the form \\n and $n ..  The
problem arises because of the $n notation in the replacement
string....  I've done a fair bit of digging and it doesn't look like
there's a way to disable the replacement.  The only thing I can think
to do would be to prepend any $'s with a double backslash via another
preg_replace prior to this one...

This seems to work :

$v = preg_replace('/(\$[0-9])/', '\\\\$1', $v);


> I ended up doing a temporary string replacement of $ to -$- and then
> string replace it back, but there ought to be a 'right' way to do
> this...  Thanks again!

Kinda the same thing as what I have, just in reverse.. :)

> Cheers.
> Dan

-- 
Jason 'XenoPhage' Frisvold
XenoPhage0 at gmail.com
http://blog.godshell.com



More information about the pmwiki-devel mailing list