[pmwiki-users] Improving a certain recipe script

Dominique Faure dominique.faure at gmail.com
Thu Mar 30 03:33:38 CST 2006


On 3/30/06, H. Fox <haganfox at users.sourceforge.net> wrote:
> On 3/29/06, Patrick R. Michaud <pmichaud at pobox.com> wrote:
> > On Wed, Mar 29, 2006 at 08:40:45PM -0700, H. Fox wrote:
> > > On 3/29/06, H. Fox <haganfox at users.sourceforge.net> wrote:
> > > > How would I test for the following in a recipe script:
> > > >
> > > > $SomeNumber = NN;
> > > > if (a line in wikitext starts with a space and has more than
> > > > $SomeNumber characters) { # Do something. }
> > >
> > > Not a line in wikitext, a line in posted wikitext.  I think it will be
> > > something like
> > >
> > > if preg_match("!^ <something>$!", @$_POST['text']) # Do something.
> > >
> > > where <something> is Perl regular-expressionese for "more than
> > > $SomeNumber characters".
> >
> > Assuming you don't need to match newlines:
> >
> >     preg_match("!^ .{$SomeNumber,}!", ...)
> >
> > If you need to count newlines in the some number of characters,
> > add an 's' modifier:
> >
> >     preg_match("!^ .{$SomeNumber,}!s", ...)
>
> It doesn't like the comma inside the curlies.
>

It seems that you hit the string variable parsing use of curlies.
I would try:

    preg_match("!^ .{{$SomeNumber},}!", ...)

Regards,
Dom




More information about the pmwiki-users mailing list