[pmwiki-devel] preg dot question...
editor at fast.st
Fri Dec 8 02:20:34 CST 2006
On 12/7/06, Patrick R. Michaud <pmichaud at pobox.com> wrote:
> On Thu, Dec 07, 2006 at 07:21:32PM -0500, The Editor wrote:
> > I have a pattern matching I'm using for a redirect markup called (:forward:).
> > It looks like this:
> > $x = preg_replace('/\(\:forward ([-.\\w]+)\:\)/e', 'Redirect($1)', $x);
> > It works fine BUT
> > when I put (:forward Group.Page:) the value passed to Redirect is
> > GroupPage. The dot disappears.
> You don't have quotes around your $1. Thus after doing the match,
> PHP replaces the $1 with the part in parentheses and sees
> and since Group.Page isn't a string, the dot gets lost. You really
> $x = preg_replace('/\(\:forward ([-.\\w]+)\:\)/e', "Redirect('$1')", $x);
> BTW, I've noticed this throughout the ZAP code, where things that
> ought to be strings aren't placed in quotes. That's generally not
> a good idea, because one never knows when a word will accidentally
> end up being a PHP function or having a meaning other than being
> a bareword string.
Ahhh, great Pm! Thank you so much. Makes sense now. Could you be a
bit more specific about the kinds of places things ought to be in
quotes, and I'll plow my way through and try to make the corrections?
Thanks again in advance.
More information about the pmwiki-devel