From: Sebastian Hungerecker Date: 2007-09-21T23:48:55+09:00 Subject: Re: gsub not working. Ruby thinks I'm in an array? Peter Bailey wrote: > Here's the lines where this starts: > registries = [] > registries = xmlfile.scan(/(.*? )<\/registration>/im) > #puts registries[100] > > registries.sort! > registries.each do |registry| > registry.gsub!(/<\/*registrationList>/, "") > > Can someone help me understand what's going on here? If you have capturing groups in your regexp, scan will return an array of arrays, so you are indeed calling gsub! on the subarrays. So either iterate over registries.flatten or call gsub! on registry[0] instead of registry. HTH, Sebastian -- Jabber: sepp2k@jabber.org ICQ: 205544826