From: botp Date: 2012-05-23T23:27:49+09:00 Subject: Re: How to replace a letter with a corresponding number On Wed, May 23, 2012 at 8:22 PM, Rich McMullen wrote: > coded_text = text.gsub(/[A-Z/,[1-26]) try >s=("A".."Z").to_a.join => "ABCDEFGHIJKLMNOPQRSTUVWXYZ" 0> text="ABCDE" => "ABCDE" > text.gsub(/[A-Z]/){|c|s.index(c)+1} => "12345"