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

Knut Alboldt pmwiki at alboldt.de
Tue Mar 20 08:50:09 CDT 2007


Patrick R. Michaud schrieb:
> 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
> 
> 
Thanks Patrick !

But sorry, it doesn't seems to work like I exspected it:

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



varname1:: value1
Referenz: : value1
(I don't want the second colon in the reference)


varname 1b:value1b
Referenz: {$:varname 1b}
(blanks in varnames => vraname is notrecognized)

varname-1c:	value1c
Referenz: {$:varname-1c}
(hyphen in varnames => vraname is notrecognized)

varname_1d:	value1d
Referenz: : value1d
(works, but same like varname1: double colon)

could you please help again ?

Thanks

Knut



More information about the pmwiki-users mailing list