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

Something along these lines?
m{ .* # match as late as possible ( ^abc$ # the abc .*? # everything up to ^def$ # the def ) }smx

Untested, and will be confused if there are mulitple def lines. In that case it helps to tokenize the input first (for example reading line by line)

Replies are listed 'Best First'.
Re^2: How do I match the closest of repeated strings?
by Anonymous Monk on Sep 29, 2008 at 09:27 UTC
    Sorry for my reply to the response below. I did not have the initial .* to eliminate the first abc strings. I knew this was straightforward. Sometimes when you get a mental block about something, you just can't figure it out no matter how much you stare at it.

    Thanks to both of you.