Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!feeder.news-service.com!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!talisker.lacave.net!lacave.net!not-for-mail From: Brian Candler Newsgroups: comp.lang.ruby Subject: Re: Can I split the array from text? Date: Sun, 24 Apr 2011 11:01:22 -0500 Organization: Service de news de lacave.net Lines: 26 Message-ID: <9d7348e487437e591621461c32a68b1e@ruby-forum.com> References: NNTP-Posting-Host: bristol.highgroove.com Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Trace: talisker.lacave.net 1303660908 21119 65.111.164.187 (24 Apr 2011 16:01:48 GMT) X-Complaints-To: abuse@lacave.net NNTP-Posting-Date: Sun, 24 Apr 2011 16:01:48 +0000 (UTC) In-Reply-To: X-Received-From: This message has been automatically forwarded from the ruby-talk mailing list by a gateway at comp.lang.ruby. If it is SPAM, it did not originate at comp.lang.ruby. Please report the original sender, and not us. Thanks! For more details about this gateway, please visit: http://blog.grayproductions.net/categories/the_gateway X-Mail-Count: 382126 X-Ml-Name: ruby-talk X-Rubymirror: Yes X-Ruby-Talk: <9d7348e487437e591621461c32a68b1e@ruby-forum.com> Xref: x330-a1.tempe.blueboxinc.net comp.lang.ruby:3439 Sira PS wrote in post #994712: > If I have an array like this > > ["Member", "Friends", "Hello", "Components", "Family", "Lastname"] > > And I need to split this array from "Components" and get 2 arrays which > are > > ["Member", "Friends", "Hello"] > > and > > ["Family", "Lastname"] > > Can I do that and how? I think this is the simplest way: a = ["Member", "Friends", "Hello", "Components", "Family", "Lastname"] i = a.index("Components") p a[0...i] p a[i+1..-1] -- Posted via http://www.ruby-forum.com/.