9fans archive / 2008 / 10 / 356 / prev next From: "Rudolf Sykora" <rudolf.sykora@gma...> Subject: Re: [9fans] non greedy regular expressions Date: Fri, 24 Oct 2008 23:40:36 +0200 > 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 :)