Extension:Whitelist Regex

What can this extension do?
If you have a private wiki, you may wish to made some groups of pages publicly readable. This extension extends the default MediaWiki Manual:$wgWhitelistRead option by allowing one to identify the whitelisted pages by their namespace and a regular expression. Thus allowing to made public either a whole namespace and/or some groups of pages, based on their title.

This work is based on Extension:Whitelist_Namespaces by User:Bawolff

Usage sample
Please note:
 * That the use of start (^) and end ($) delimiters in the regular expression is strongly encouraged. Otherwise a partial match will be made. As an example, You are not Welcome will match !Welcome! but not !^Welcome$!.
 * In all examples of this page, I use a bang (!) as delimiter for the regular expression instead of the most usual slash (/) since the later will clash with some page titles – notably in sub-pages (and I find the use of a backslash to shield it both less readable and more error prone).

Download instructions
Please cut and paste the code found below and place it in. Note: $IP stands for the root directory of your MediaWiki installation, the same directory that holds LocalSettings.php.

Installation
To install this extension, add the following to LocalSettings.php:

Configuration parameters
The global variable $egRegexReadWhitelist holds an array with an entry for each namespace (identified by their numeric ID) handled by this extension. In its turn, each entry holds an array of PCRE regular expressions. Any page matching one of the regular expressions in the corresponding namespace entry will be read-whitelisted. Here are some examples:
 * $egRegexReadWhitelist[NS_MAIN][] = "!^(Accueil|Main Page)$!"</tt>
 * Grant anyone read access to the pages Accueil</tt> and Main Page</tt> in the main (NS_MAIN</tt>) namespace. Please note that a space is used in Main Page, since the pattern is matched against the title text – not the DB key (i.e.: by using _ instead of space).


 * $egRegexReadWhitelist[NS_USER][] = "!^Sylvain$!";</tt>
 * Grant anyone read access to the Sylvain</tt> page in the User</tt> namespace.


 * $egRegexReadWhitelist[NS_USER][] = "!^Sylvain/public/.*$!"</tt>
 * Grant anyone read access to any sub-page of Sylvain/public/</tt> in the User</tt> namespace.


 * $egRegexReadWhitelist[202][] = "!.*!";</tt>
 * Grant anyone read access to any page in the namespace whose id is 202 (but not to the corresponding talk pages).