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: Joey Zhou Newsgroups: comp.lang.ruby Subject: Re: Can I split the array from text? Date: Sun, 24 Apr 2011 08:21:44 -0500 Organization: Service de news de lacave.net Lines: 14 Message-ID: <6d8f6a42e814dec670357ff39a49eee6@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 1303651330 4660 65.111.164.187 (24 Apr 2011 13:22:10 GMT) X-Complaints-To: abuse@lacave.net NNTP-Posting-Date: Sun, 24 Apr 2011 13:22:10 +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: 382119 X-Ml-Name: ruby-talk X-Rubymirror: Yes X-Ruby-Talk: <6d8f6a42e814dec670357ff39a49eee6@ruby-forum.com> Xref: x330-a1.tempe.blueboxinc.net comp.lang.ruby:3432 Maybe you can refer to Enumerable#slice_before Here's a sample code: a = ["Member","Friends","Hello","Components","Family","Lastname"] b = a.slice_before {|elem| elem == "Components" }.to_a p b[0] #=> ["Member", "Friends", "Hello"] p b[1] #=> ["Components", "Family", "Lastname"] Joey -- Posted via http://www.ruby-forum.com/.