> >>>>> "W" == Wayne Blair <wayne.blair / relian.com> writes: > > W> Is this normal? It looks like $& ends up being a hungry match, but not = > W> the String#scan result. > > Well, String#scan is defined like this in ruby-man > > scan(pattern) > scan(pattern) {...} > > Returns the array of arrays which contain subpatterns > corresponding parentheses in the pattern. Match will be done > repeatedly to the end of the string. When called with the > block, subpatterns are passed to the block as parameters. > > For me, the result is correct > > > Guy Decoux The array of arrays it returns does not contain all subpatterns, it only contains the least hungry match possible in a one element array in a one element array array. In a regular match, it returns the hungriest match in a String. You're explanation doesn't shed any light on that. irb> a.scan(regex) [["\\\""]] # this is strange result - $& is what I expected in some way in result irb> print $& "\"hello\""nil # this result is the hungriest match Wayne