Hello --

On Fri, 5 Jan 2001, Jens Luedicke wrote:

> Hi there ...
> 
> I have a problem with tr! ...
> 
> array = ['b', 'c', 'd']
> for i in array 
>     i.tr!("b", "X")
>     print i, "\s"
> end
> 
> the above example would replace the "b" with an "X",
> but how can I use a Regexp like
> 
> tr!(/b-y/, /a-z/)
> 
> But this doesn't work and I get an error message.

#tr takes strings as its arguments, not regular expressions.  So....

  str.tr!('b-y', 'a-z')

Full example:

   irb 6> a = %w{ b c d }
      ==>["b", "c", "d"]
   irb 7> a.each do |let| let.tr! 'b-y', 'a-z' end
      ==>["a", "b", "c"]


David

-- 
David Alan Black
home: dblack / candle.superlink.net
work: blackdav / shu.edu
Web:  http://pirate.shu.edu/~blackdav