in reply to Re^2: How to find the outermost pair of square brackets with a regex?
in thread How to find the outermost pair of square brackets with a regex?

That code is broken.

our $re local $re = qr{\[(?:(?>[^\[\]]+)|(??{$re}))*\]}; for (;;) { last unless $tempstr =~ s/(\[\w+?\s*=\s*($re|\n|[^\[\] +])+\])/assign($1)/gie; }

It's unfortunate that you modify things without knowing why they were done in the first place.

Replies are listed 'Best First'.
Re^4: How to find the outermost pair of square brackets with a regex?
by lokiloki (Beadle) on Jan 17, 2007 at 20:35 UTC
    thanks...

    i guess part of the problem, and perhaps why i was using the s modifier, was because how can something like the following also match for newline?

    [^\[\]]

    since this matches everything BUT [ or ], shouldn't it also match newline? if not, what modifier can force it to match such?

    i couldnt figure that out, which is why i opted for this alternation:

    ($re|\n|[^\[\]])+

      [^\[\]] does match newline.

      >perl -le "print( qq{\n} =~ /[^\[\]]/ ?1:0) 1