[pmwiki-users] Problem with $SearchPatterns

Petko Yotov 5ko at 5ko.fr
Sun Jun 29 08:22:32 CDT 2008


On Sunday 29 June 2008 11:22:01 Kai Bühler wrote:
> One last question: I understand that the ! is the exclude parameter, but
> I didn't find if I have to use \\ or \ behind my group?
> What's the difference between \ and \\ ? Are both wildcards? In my case
> it works and it does not find content which is e.g. in Group P0035, but
> I would like to understand it 100% ;-)
> Is there an explanation article around which explains ^, \ ?

It is generally a double backslash, when the regular expression inside quotes 
(double or single).

^, dot, \, $, *, /, +, (, ), [, ], {, } and others have special meanings in 
regular expressions therefore they are escaped with a \ when we need a 
literal dot. (inside quotes, \ has special meaning, so we use a double \).

A regular expression has a starting character, in our case / or !, then the 
pattern, then an ending character same as the starting one, then possibly 
some "modifiers".

See http://php.net/manual/en/regexp.reference.php for a full reference, and 
http://php.net/manual/en/reference.pcre.pattern.modifiers.php for the 
modifiers.

Your expressions could be written in many ways like:

 $SearchPatterns['default'][] ="/^(De|CRM|FAQ|Glossar)\\./"; # allowed
 $SearchPatterns['default'][] ="!^P.*\\.!"; # excluded

The last one, ^P.*\\. is actually what you need as you wish to exclude groups 
starting with P, e.g. P0034, P0056 (and not ^P\. which excludes only the 
group "P").

Thanks,
Petko



More information about the pmwiki-users mailing list