From: "Peña, Botp" Date: 2008-07-15T20:54:55+09:00 Subject: Re: Extracting range of lines From: tmarc [mailto:tmarciniak@gmail.com] # are there a ruby equivalents to perl's /regex/ .. /regex/ and / # regex/ ... /regex/ idioms, examples described at # http://www.unix.com.ua/orelly/perl/cookbook/ch06_09.htm? # I've been googling around with no relevant results. try searching for ruby+range+flip+flop iianm, *that* perl/sed style is being deprecated. eg, File.open("test.txt") do |f| while line=f.gets p line end end "--first\n" "1234\n" "456\n" "4321\n" "654\n" "--second\n" "546\n" "3456\n" "5436\n" "9879\n" "--third\n" "1111\n" #=> nil File.open("test.txt") do |f| while line=f.gets p line if line =~ /^--second/ .. /^--third/ end end "--second\n" #=> nil so you get weird results. the new ruby syntax is like, File.open("test.txt") do |f| while line=f.gets p line if line =~ /^--second/ .. line =~ /^--third/ end end "--second\n" "546\n" "3456\n" "5436\n" "9879\n" "--third\n" #=> nil hth. kind regards -botp