From: David Alan Black Date: 2001-10-30T20:37:27+09:00 Subject: [ruby-talk:23834] Re: Probably a simple one Hello -- (Disclaimer: I am aware of the fact that HTML cannot be parsed with a single regular expression. I just want to help the guy grasp the syntax :-) On Tue, 30 Oct 2001, Ralph Mason wrote: > Thanks Joe, > > I can see how your expression works however I still mystified by the > behavior of my one. > > If .* will just keep matching to the end of the line then my version should > have returned nil as the whole expression would never have been matched. > But it didn't > > I have just been playing with this > > z="abc" > z=/(.*b)/ => 0 > $1 => "ab" > z=~/(.*)b/ => 0 > $1 => "a" > > So it seems that .* is matching in this case until it finds the character > following. But in the example below it doesn't. It seems to randomly stop. No, it stops at exactly the point you've asked it to :-) > > RM> s="xxx " > > RM> s =~ /<.*A.*href *= *"(.*)".*>/ => 0 > > $1 =>> "l.htm\">xxx xxx " s =~ /<.*A.*href *= *"(.*?)".*>/ # $1 => l.htm David -- David Alan Black home: dblack@candle.superlink.net work: blackdav@shu.edu Web: http://pirate.shu.edu/~blackdav