Thanks to all who tried to help.  Here's the final answer.


#!/usr/bin/env ruby
string="The quick brown fox jumped over the lazy dog"
def get_subsection(word, sentence)
sentence.scan(Regexp.new(/(?:\W{0,1}\w+\W){0,3}over(?:\W{1}\w+){0,3}/))
end

puts get_subsection("quick", string)
puts get_subsection("lazy", string)
puts get_subsection("fox", string)
puts get_subsection("dog", string)


The regex in the middle of the syntax is where I struggled, but with a 
little bit of help from the guru I was able to solve the problem.

-- 
Posted via http://www.ruby-forum.com/.