From: Jimmy Thrasher Date: 2001-10-25T22:55:23+09:00 Subject: [ruby-talk:23295] Re: [RegEx] What dose _.tr! At 10:34 PM 10/25/2001 +0900, you wrote: > Hi Folks, > >frist of all I'm new to Ruby, but I think Ruby is high on my time-table to >learn ;-). > >Can you explain me the what the tr in this the Regex does? > >$_.tr! "A-Za-z", "N-ZA-Mn-za-m"; String#tr! does an in-place replacing of characters. In this case, it's like an array mapping, where if you match a character at index 13 in "A-Za-z" (namely 'N'), it will replace it with the character at index 13 in "N-ZA-Mn-za-m" (namely 'A'). So, in irb: irb(main):007:0> "ABCabc".tr!("A-Za-z", "N-ZA-Mn-za-m") "NOPnop" Jimmy