From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: Date: Fri, 24 Oct 2008 23:40:36 +0200 From: "Rudolf Sykora" To: "Fans of the OS Plan 9 from Bell Labs" <9fans@9fans.net> In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <765ef13a653652d5fcef9001ff70f814@quanstro.net> <20081024170237.68ED28DE7@okapi.maths.tcd.ie> Subject: Re: [9fans] non greedy regular expressions Topicbox-Message-UUID: 26f14afc-ead4-11e9-9d60-3106f5b1d025 > Greedy leftmost-first is different from leftmost-longest. > Search for /a*(ab)?/ in "ab". The leftmost-longest match > is "ab", but the leftmost-first match (because of the > greedy star) is "a". In the leftmost-first case, the greediness > of the star caused an overall short match. Ok, I finally see the point... thanks. Only one last question: So is there any simple way (using existing regexps) to find 'the interesting parts' in my last example?: ABCthe_interesting_partCBA blabla bla ABCthe_interesting_partCBA ... ...i.e. delimited with ABC from the left and CBA (or e.g. EFG) from the right? Say I have a file with such a structure and want to only get 'the interesting parts' form it. > >> All the thinking about this is simply removed with 'non-greedy' ops. > > But it isn't (or shouldn't be). well, I admit it isn't :)