[Pmwiki-users] (Beta13+) Want to swap {{ }} for [[ ]])

Patrick R. Michaud pmichaud
Sun Feb 15 20:06:00 CST 2004


On Mon, Feb 16, 2004 at 08:04:22AM -0800, Steven Leite wrote:
> 
> >    $GroupNamePattern="[[:upper:]][[:alnum:]]+";
> 
> Not that anyone want to do this, but suppose you wanted to allow for a
> $GroupNamePattern to consist of any upper or lower case letter, follow more
> ZERO or more character (Thus allowing for page Titles to be of one character
> in length).  How could you change the following expression to do that?

You have two questions here.  The $GroupFreeLinkPattern (for *page titles*)
already allows page titles to be one character in length.  The 
$GroupNamePattern (for *group names*) requires at least two characters
by default, but if you wanted to allow a group name of a single uppercase
letter you can change the last '+' to a '*':

    $GroupNamePattern="[[:upper:]][[:alnum:]]*";

> >    $FragmentPattern="#([A-Za-z][-.:\\w]*)";
> 
> Can you briefly explain what the purpose of the $FragmentPattern is and when
> it's used?

It's used at the end of URLs to jump to anchors in the middle of the
page text, as in 
    http://www.pmichaud.com/wiki/PmWiki/TextFormattingRules#BulletedLists

> >    $PageTitlePattern="[[:upper:]][[:alnum:]]*(?:-[[:alnum:]]+)*";
> >
> > A page's title (name) consists of an uppercase character ([[:upper:]]),
> > followed by zero or more alphanumeric characters ([[:alnum:]]*).
> > Hyphens can exist in page names, but each hyphen must be immediately
> > followed by at least one alphanumeric character.
> 
> How would you modify the $Pattern (above) to remove the restriction on
> hyphens?
> For example, allowing a page title:
> My - - New -- Page - - -"

Well, spaces aren't allowed in page names, but if you mean to use underscores
for the spaces

   $PageTitlePattern="[[:upper:]][-\\w]*";

allows any uppercase character followed by zero or more word characters
(letters, digits, underscores) and hyphens.

> If all this (useful) talk about creating/modifying and understanding
> regexpression were to be in the documentation somewhere, what is a good
> category/page title for it?  

I'd put it in the Cookbook for now--i.e., to allow group names of one
letter, do this; to allow multiple hyphens, do this; to have spaces
in free links converted to underscores, do this, etc.

Pm



More information about the pmwiki-users mailing list