in reply to Re: How do I match the closest of repeated strings?
in thread How do I match the closest of repeated strings?

That will match everything from the first abc to the first def, not not everything starting from the closest abc (which I believe is what the OP wants).

But it can be adapted, of course:

m{ ( ^abc$ (?:(?!^(?:def|abc)$).)* ^def$ ) }smx