Sebastian Hungerecker
9/21/2007 4:04:00 PM
Peter Bailey wrote:
> > Peter Bailey wrote:
> >> registries.sort!
> >> registries.each do |registry|
> >> registry.gsub!(/<\/*registrationList>/, "")
>
> Thanks, Sebastian. OK, I did a .flatten, which I read more about and
> looks like a very cool method. Now, I don't get an error message, but, I
> don't get any substitutions either!
Yes, I didn't notice this the first time because I was only focussing on the
error you were getting, but the gsub! is basically useless there. You're
using it to modify registry which is thrown away at the end of the iteration.
each doesn't modify the array over which it iterates for that you want map:
registries.map! do |registry|
registry.gsub(/<\/*registrationList>/, "")
end
(This assumes that registries is already flattened, otherwise use registry[0]
instead of registry. Thinking about it that might actually be better because
it saves you the flatten step)
> You suggest doing a gsub! on
> registry[0], but, that's just the first entry.
registry only ever has one entry because the scan regex has only one capturing
group.
HTH,
Sebastian
--
Jabber: sepp2k@jabber.org
ICQ: 205544826