On Wed, Nov 16, 2011 at 09:34:58PM +0100, Olof Johansson wrote: > On 2011-11-16 14:14 -0500, Ronald J Kimball wrote: > > It's working as expected for me, so I'm not sure what needs to be fixed. > > Hum, now I'm ashamed. Sorry. But why is that not greedy? (I got other > results earlier, but I can't reproduce now so I have probably made an > error in my earlier attempts.)
It is greedy, but the important thing to remember is that the regular expression engine will find the longest *leftmost* match. For example, "00111000" =~ /0*/ will match "(00)111000". It won't match "(0)0111000", because, although it's a leftmost match, it's not the longest leftmost match. And it won't match "00111(000)" because that's not a leftmost match, regardless of the length. Ronald