in reply to •Re: left-non-greedy regex?
in thread left-non-greedy regex?

How about doing the same thing as the existing minimal match - just starting from the other side. Of course you can do that by reversing the search string and than doing the existing minimal match.

Update: This was the conclusion of the MarkM post later here - so I was not the first with this idea.

Replies are listed 'Best First'.
•Re: Re: •Re: left-non-greedy regex?
by merlyn (Sage) on Mar 26, 2003 at 14:45 UTC
    That'll just find the first match, with a minimal span within that match. That's still not going to find the shortest of all possible matches.

    In other words, it won't find the middle "b" in "abbababba", if you're looking for the "shortest run of b's" as in the other node.

    -- Randal L. Schwartz, Perl hacker
    Be sure to read my standard disclaimer if this is a reply.

      In his post he proposed two hipothetical maching construct - my answer was concerning the first what he called 'left non greedy', you talk rather about the 'both left and right non greedy'.