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
In reply to Re^2: Regex question - negatives
by JavaFan
in thread Regex question - negatives
by ultranerds
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |