From: Robert Klemme Date: 2010-07-24T02:03:30+09:00 Subject: Re: how to convert the string? On 07/23/2010 03:45 PM, Pen Ttt wrote: > i want to convert a string "-34\n \302\240" into "-34" > irb(main):001:0> "-34\n \302\240".gsub('\302\240','').strip.chomp > => "-34\n \302\240" > how to convert it? As others have indicate it is a bit unclear what strings you expect. If you want the first integer you can do irb(main):001:0> s = "-34\n \302\240" => "-34\n " irb(main):002:0> s.to_i => -34 irb(main):003:0> s[/^[-+]?\d+/] => "-34" irb(main):004:0> Kind regards robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/