Jesús Gabriel y Galán wrote: > 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 "sturkols" | sed -e 'y//aae/' >> asturakolse >> >> Alike, I'd do something like "oll".gsubm("","aeu") which would >> return "aolelu" > >> p "Leeind".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. The "strange chars" are common chars in Brazilian Portuguese and Portuguese as well as other languages. e.g.: francês, inglês, pátria, nação, aeroviário, silábica, and so on. Ruby wasn't designed to deal with those chars in the same way you can deal with english-only chars. "som".tr('sm','NM') #=> "NoM" "cruxificação".tr("çã","ca") #=> "cruxificaaaaao" $ ruby --version ruby 1.8.6 (2007-09-24 patchlevel 111) [i686-linux] Maybe it's better to use a system() call and execute sed or start learning some other language like perl. Thanks once again. -- Posted via http://www.ruby-forum.com/.