On Jun 4, 8:35=A0am, Intransition <transf... / gmail.com> 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:
>
> =A0 require 'facets/hash/rekey'
>
> =A0=A0 searchReplacePairs.rekey! do |search, replace|
> =A0=A0 =A0 search.class =3D=3D String ? Regexp.new(search) : search
> =A0=A0 end

Slight correction:

  searchReplacePairs.rekey! do |search|
     search.class =3D=3D String ? Regexp.new(search) : search
   end

Which gives me an idea about a possible improvement to the method ;-)