[pmwiki-users] pattern matching:

Stirling Westrup sti at pooq.com
Sat Dec 23 11:02:32 CST 2006


The Editor wrote:
> Now that I'm getting the hang of expressions, I have a simple
> question.  Why does Pm generally use double escapes \\ rather than
> single escapes \.
> 
> Here's an example he sent me awhile back.  I think I understand the rest of it:
> 
>>>>     preg_replace('/\\{([-.:\\w]+)\\}/e', "Function('$1')", $text)
> 
> Just curious, and trying get a bitter better at this kind of thing.
> 

PM has answered this question a couple of times that I can remember. Search
the archives for a definitive answer.

In short, IIRC, its because there are certain obscure cases where you need the
double escapes. Rather than having to try and figure out when those cases
occurs, he just always puts them in. This is, surprisingly, safe to do because
of how PHP handles escapes.






More information about the pmwiki-users mailing list