in reply to Re^5: Match a pattern only if it is not within another pattern
in thread Match a pattern only if it is not within another pattern

Well, technically the OP does say "surrounded", ...
Actually not.


Read again:
# replace all foo(s) above with 123 except for the ones that are # surrounded by bar and qux
to me it's conceivable that it also meant the reverse of bar.+qux, although it is a stretch. I agree that the examples do not indicate this, however.

My ability to conceive of an application where reversible bracketing would make sense is irrelevent, but it really does only make sense on a primary, un-nested level, e.g.
bar foo qux qux foo bar qux foo bar bar foo qux

whereas these are already covered by the base case:
bar qux foo bar qux bar foo qux foo bar foo qux
although the first one could be seen as overlapping nesting and then we get into a whole 'nother realm of questions =) In any case, I agree that, except in extreme cases, your original response would be more than sufficient. I am merely trying to present another possible interpretation.