On Sun, Aug 29, 2010 at 12:02 PM, Pen Ttt <myocean135 / yahoo.cn> wrote:
> i want to make 'gkhj*&()' into 'gkhj',here is my code
> item='gkhj*&()'
> item=item.map{|echar|
> if /[a-z]/=~ echar then
>  echar=echar
> else
>  echar=''
> end}
> puts item
> why i can't get what i want?
> Any advice appriciated.

Much easier to use gsub with a negative character set for this:

  puts item.gsub(/[^a-z]+/, '')

HTH,
Ammar