in reply to Why is this greedy matching?

"First match" (leftmost) trumps "shortest match" (anti-greedy). You can use a greedy .* to replace "leftmost (sub)match" with "rightmost (sub)match" to end up with "shortest match" in cases like this:

m{.*/(.*\.gz)$}

Note that it doesn't matter whether you make the part inside the parens greedy or not here.

- tye