[pmwiki-users] PageTextVariable: own "automatic variable" format

Patrick R. Michaud pmichaud at pobox.com
Tue Mar 20 07:28:55 CDT 2007


On Tue, Mar 20, 2007 at 11:28:11AM +0100, Knut Alboldt wrote:
> I tried to add "my" format using the following statement:
> 
> $PageTextVarPatterns['var::'] = '/^([a..zA..Z_-\/]*)\\s*::[ \\t]?(.*)$/m';
> but that doesn't work

PCRE uses hyphens to indicate character ranges instead of '..',
so you probably want

  $PageTextVarPatterns['var::'] = 
    '/^([-a-zA-Z_]+)\\s*::[ \\t]?(.*)$/m';

> And how can I suppress trailing spaces in the value-part ?

Perhaps

  $PageTextVarPatterns['var::'] =
    '/^([-a-zA-Z_]+)\\s*::[ \\t]?(.*?)\\s*$/m';

And I'm assuming that you're deliberately not allowing digits
in your page text variables... if you want digits also, then

  $PageTextVarPatterns['var::'] =
    '/^(\\w[-\\w]*)\\s*::[ \\t]?(.*?)\\s*$/m';

This last version also prevents a page text variable from
beginning with a hyphen.

Pm



More information about the pmwiki-users mailing list