BrendanC wrote: > I have the following text in a file: > > 1 a1.html > 2 b.doc > 3 c.xml > 4 d.tiff > 5 e.jpeg > 6 f.html > .... > > I need a regexp to match lines except those that end with ending in > ".html" - iow - I want lines 2-5 above. Some alternate means to the same end: IO.foreach("data.txt") do |line| #1 if line.chomp.split(".")[-1] != "html" puts line end #2 if line[-5, 4] != "html" print line end #3 if line.slice(-5..-1) != "html" print line end puts end --output:-- 2 b.doc 2 b.doc 2 b.doc 3 c.xml 3 c.xml 3 c.xml 4 d.tiff 4 d.tiff 4 d.tiff 5 e.jpeg 5 e.jpeg 5 e.jpeg -- Posted via http://www.ruby-forum.com/.