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.
You can't declare $re on the same line as you're using it. It won't even compile (under strict vars).
There's a I reason I used a package variable instead of a lexical. It'll bite you if you interpolate into $re. Best to always use a package variable to avoid the problem entirely.
While not a bug per say, the s modifiers on both regeps are useless because you don't use ..
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 | |
by ikegami (Patriarch) on Jan 17, 2007 at 20:43 UTC |