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
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.