[pmwiki-users] Improving a certain recipe script

Patrick R. Michaud pmichaud at pobox.com
Thu Mar 30 12:46:29 CST 2006


On Thu, Mar 30, 2006 at 11:39:16AM -0700, H. Fox wrote:
> On 3/30/06, Patrick R. Michaud <pmichaud at pobox.com> wrote:
> > On Thu, Mar 30, 2006 at 11:33:38AM +0200, Dominique Faure wrote:
> > > > > Assuming you don't need to match newlines:
> > > > >
> > > > >     preg_match("!^ .{$SomeNumber,}!", ...)
> > > > 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},}!", ...)
> >
> > Dominique is likely correct, and I like the way he's written it
> > here.  I would've done
> >
> >     preg_match("!^ .\{$SomeNumber,}!", ...)
> >
> > but I think the double-curly form may be more reliable.
> 
> Neither of those is successful , nor is this:
> 
>     if (preg_match('!^ {.4,}$!s', $_POST['text'])) {

The dot goes outside the curlies, the comma goes inside the curlies, 
as in:

      if (preg_match('!^ .{4,}$!', $_POST['text'])) {

See, for example, http://www.pmichaud.com/sandbox/pattern.php .
The meaning is match any character (.) four or more times ({4,}).

Pm




More information about the pmwiki-users mailing list