From: Ron Coutts Date: 2003-12-16T08:12:03+09:00 Subject: Re: Extracting multiple lines from a file > If the file is a reasonable size, if might be easier to do > > content = File.read("ordinal") > content.scan(/^START(.*?)^END/m) do |match,| > p match > end > > This reads in the whole file, then calls the block passing in the > chunks of it between START and END. > Thanks Dave and Rodrigo for your regex solutions. The file is small enough so the solution above is good. I got the part that reads the block content down to one line because I have a multiple content blocks to extract from the same file. Here it is. content = File.read("ordinal") block_content = content.scan(/BEGIN\n(.*?)END\n/m).join If anyone's doing a Ruby Cookbook, please throw in this solution, or one like it! :) Thanks all for your quick replies. Much appreciated! Ron P.S. I was using Ruby 1.8.0