From: Pascua 9804 Date: 2011-09-15T00:55:34+09:00 Subject: Re: Tough Ruby Homework Darryl Pierce wrote in post #1021946: > On Wed, Sep 14, 2011 at 11:27:08PM +0900, Rory Pascua wrote: >> Not a school homework. Its a work homework. Thanks > > I think that makes no difference. What have _you_ done first to attempt > to solve this? I know.. I know.. My post sounded like I didn't even try because I went straight to the question without even explaining what I did. Well here's what I did. #!/usr/bin/env ruby string="The quick brown fox jumped over the lazy dog" def get_subsection(word, sentence) sentence.scan(Regexp.new(word)) end puts get_subsection("quick", string) puts get_subsection("lazy", string) puts get_subsection("fox", string) puts get_subsection("dog", string) I just need the REGEX portion to select the three words on both sides and right now I'm struggling with it. I tried looking at "lookaround" but it got me even more confused. -- Posted via http://www.ruby-forum.com/.