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

Why? Very often the specific application makes a big difference to choosing a good solution. Either the solution is fairly trivial (/.*abc(.*?)def/sm) or there is a bunch of context you are not telling us about.


Perl reduces RSI - it saves typing

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:19 UTC
    I tried that (as it seemed like the obvious thing to do), but it didn't work. I got the match from the first abc up to the def.
      'xyz abc 123 abc pqr abc get this bit def ijk abc lmn' =~ /.*abc(.*?)d +ef/sm; print ">$1<";

      Prints:

      > get this bit <

      which is what I understood you to want.

      Update: Ah, I see it did do what you want. ;)


      Perl reduces RSI - it saves typing