in reply to Re^3: 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?

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|[^\[\]])+

Replies are listed 'Best First'.
Re^5: How to find the outermost pair of square brackets with a regex?
by ikegami (Patriarch) on Jan 17, 2007 at 20:43 UTC

    [^\[\]] does match newline.

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