From: "Jörg W Mittag" Date: 2010-07-24T00:25:06+09:00 Subject: Re: how to convert the string? 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? > thinks for your help. Does the string have *any* kind of random data at the beginning or is it always an integer? In the latter case, you could simply parse the number and convert it back into a string: "-34\n \302\240".to_i.to_s # "-34" jwm