[Pmwiki-users] DevQ: $PageTitlePattern

Patrick R. Michaud pmichaud
Fri May 14 14:13:17 CDT 2004


On Thu, May 13, 2004 at 03:28:08PM -0700, Steven Leite wrote:
>    I need this translated please:
> 
>    $PageTitlePattern="[[:upper:]][[:alnum:]]*(?:-[[:alnum:]]+)*";

Scott gave a translation already, but I'll give my less technical
sounding one here.  A page title starts with an uppercase letter
followed by zero or more letters and digits.  In addition, a page
title can contain hyphens, but only if each hyphen is followed
by at least one letter or digit.

>    Besides  the  regex translation, I also want to know specifically what
>    is included in the character classes:
>    [[:upper:]] and [[:alnum:]], (and what do they not include).

[:upper:] is the set of uppercase letters in the current locale.
[:lower:] is the set of lowercase letters in the current locale.
[:alpha:] is all letters, the combination of [:upper:] and [:lower:]
[:digit:] is all digit characters in the current locale.
[:alnum:] is all alphanumeric characters -- i.e., [:alpha:] and [:digit:]

In Perl-based regexps (which is what PmWiki uses), \d is equivalent to
[[:digit:]], and \w is equivalent to [[:alnum:]_] (alnum + underscore).

>    What  implication  might arise in making changes to this variable (eg.
>    loosening  it  a bit to allow digits, or space or underscores, or even
>    allowing any character).

It already allows digits, just not as the first character.  Adding them
doesn't appear to be a serious problem.  Allowing spaces in page titles
is probably a bad idea, since spaces cannot appear natively in URLs and
lots of things may parse based on whitespace.  Underscores present no 
real problem, but you may want to design the pattern to avoid 
_leadingunderscore and My_______page___with__lots__of__underscores,
especially if someday the __ sequence is used for markup.

When designing PmWiki, I've tried to err on the side of
restrictiveness in patterns rather than permissiveness for initial
implementations.  From a software upgrade/evolution perspective, 
it's much easier to make patterns more permissive over time ("we 
now support something that wasn't there before") than it is to make 
them more restrictive ("we no longer allow something that a lot of 
pages and systems depend on").  

Pm



More information about the pmwiki-users mailing list