On Jan 9, 2008 2:44 AM, Ckvok Kovsky <mr.oliveira / gmail.com> wrote:
> Hello. I'm a ruby newbie.
> I'd like to make a "mass substitution" version of gsub, like in the sed
> example:
>
> $echo "turols | sed -e 'y/aae/'
> asturakolse
>
> Alike, I'd do something like "l.gsubm(","aeu") which would
> return "aolelu"

> p "Leein".gsubm(",'a')a
>
> I didn't get success in any case. I've searched a lot also, but couldn't
> find any solution.

Maybe tr will work for you:

irb(main):012:0> "abcdefghijk".tr "abc", "123"
=> "123defghijk"

It supports character ranges, and padding the second argument
with its last character if it's shorter than the first one:

"hello".tr('aeiou', '*')    #=> "h*ll*"
"hello".tr('^aeiou', '*')   #=> "*e**o"
"hello".tr('el', 'ip')      #=> "hippo"
"hello".tr('a-y', 'b-z')    #=> "ifmmp"

I was having some problems testing your cases, I think because of the
strange chars, maybe that's the source of your problems too?

Hope this helps,

Jesus.