[pmwiki-users] ZAP nearly ready...

Craige Leeder craige at internetadvisor.ca
Mon Oct 23 12:55:34 CDT 2006


The Editor wrote:

>Oh one extra question I forgot to ask before...
>
>Can someone help rewrite this expression pattern so it does not
>execute for something like {$var}, {=$var} or {$:var}, etc (ie with a
>$ sign), but it does execute for {var}.
>
>$_POST[$field] = preg_replace('/\\{(.*?)\\}/e', "\$_POST[$1]", $value);
>
>I can't seem to figure out how to do negatives...
>
>Thanks again so much for all your help!
>
>Cheers,
>Caveman
>
>  
>
This may or may not work,  but give it a try:

Instead of trying to not match the dollar sign, you could try to match 
it 0 times. Sounds almost the same, but not quite. Take a look at this 
expression:

/\\{\${0}(.*?)\\}/e

It first checks to see if the dollar sign is there, and then the expression fails due to the 0 recursive operation: it want's to match it 0 times, which it has already over done. This, the expression should fail. And because all this happens before it gets to the (*?), the dollar sign will be caught before it reaches the point where it could pass.

Like I said, I'm not sure if it'll work, I'm no expert at regular expresisons, but give it a try. I think it should.

- Craige
-- InternetAdvisor






More information about the pmwiki-users mailing list