Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!news.swapon.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Robert Klemme Newsgroups: comp.lang.ruby Subject: Re: String problem Date: Sat, 23 Apr 2011 00:04:13 +0200 Lines: 30 Message-ID: <91ecb8F9dsU1@mid.individual.net> References: <47e7c58ad0690ad17efbca10bcbafbf6@ruby-forum.com> <21ab86409f391aab83c7c7b490d2c713@ruby-forum.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: individual.net hNbcsVCA26ZltDQjdZlckQ8BJnfDFsKZU00gwS7FpxJWMv39M= Cancel-Lock: sha1:05MtUROgttsit5/lXwimecO5h5c= User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.2.15) Gecko/20110303 Lightning/1.0b2 Thunderbird/3.1.9 In-Reply-To: <21ab86409f391aab83c7c7b490d2c713@ruby-forum.com> X-Antivirus: avast! (VPS 110422-1, 22.04.2011), Outbound message X-Antivirus-Status: Clean Xref: x330-a1.tempe.blueboxinc.net comp.lang.ruby:3392 On 20.04.2011 18:54, Cyril Jose wrote: > Hans Mackowiak wrote in post #994076: >> str = ">Hello World\n" >> str[1..-2] #=> "Hello World" > > Forgot to mention that I have a bunch of these types of strings of all > different lengths...thanks for the quick reply however! Hans's suggestion does work with different length strings irb(main):001:0> 5.times {|i| s="a"+("b"*i)+"x";puts s, s[1..-2]} ax abx b abbx bb abbbx bbb abbbbx bbbb => 5 Kind regards robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/