in reply to Re: Regex question - negatives
in thread Regex question - negatives
To prevent that, you need a negative look-ahead:No, you don't.
This uses some classical loop-unrolling, and is, IIRC, similar how Mastering Regular Expressions (first edition) matches C comments.$_ = "[[foo]] bar [[baz ] qux]] [quux]] fred [[waldo]]]"; say $1 while /\[\[([^]]*(?:\][^]]+)*)\]\]/g; __END__ foo baz ] qux waldo
|
|---|