From: Simon Strandgaard Date: 2004-05-14T23:36:45+09:00 Subject: Re: Regexp Error? Simon Strandgaard wrote: > On Fri, 14 May 2004 23:21:27 +0900 > ts wrote: > > > >>>>> "S" == Simon Strandgaard writes: > > > > S> ts wrote: > > S> [snip] > > >> What do you expect with ? > > >> > > >> /(.*).*/ =~ "abc" > > > > S> According to the left-most-longest rule.. I would guess the output > > S> should be ["abc", "abc"].. > > > > Then you have make .* match *twice* :-) > > > > If the regexp can't match the empty string in the second .* (because it's > > included in the first), it must not give a result > > I don't understand you here.. (maybe your assumption is wrong) ? > > > Lets break it down > > 1) The left-most .* will first eat to the end of input, and will now contain "abc". > Then it hits end of input. > > 2) the left-most .* backtracks one time > > 3) The right-most .* eats to end of input... it now contains "" > > 4) the left-most .* backtracks one time ^^^^^^^^^ right-most > > 5) Done. > > -- > Simon Strandgaard >