From: Intransition Date: 2011-06-04T21:39:13+09:00 Subject: Re: Best way to replace hash keys On Jun 4, 8:35 am, Intransition wrote: > I'm not sure your example actually works, I think you'll end up with > both string AND regexp keys. > > Here's an alternative: > >   require 'facets/hash/rekey' > >    searchReplacePairs.rekey! do |search, replace| >      search.class == String ? Regexp.new(search) : search >    end Slight correction: searchReplacePairs.rekey! do |search| search.class == String ? Regexp.new(search) : search end Which gives me an idea about a possible improvement to the method ;-)