From: Michael Campbell Date: 2004-05-14T22:34:47+09:00 Subject: Re: Regexp Error? ts wrote: >>>>>>"R" == Robert Klemme writes: > > > R> irb(main):025:0> "123-456".gsub(/.*$/, 'X') > R> => "XX" > > R> Applying your explanation, one would have to say that "$" is matched > R> twice. IMHO this is not correct. Or is there another explanation why > R> this gsub happens to return "XX"? > > This is the same explanation. Your regexp means match a string which is at > the end (where end can be \n or the end of string, in this case) > > * first match : "123-456" > * now it's at end > * it can match the empty string > > > $ is like ^ : it don't match a character but a position in the string > (sort of ...) Does *ANY* other language that you know of have this behavior? What advantage does it give Ruby to have it? (In other words, this seems to me like "it's not a bug, it's a feature!" type issue.) __________________________________ Do you Yahoo!? SBC Yahoo! - Internet access at a great low price. http://promo.yahoo.com/sbc/