From: "David A. Black" Date: 2009-07-17T09:59:53+09:00 Subject: Re: regexp exclusion search - find matches NOT ending with a string? Hi -- On Fri, 17 Jul 2009, 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. I believe this may require a > negative lookbehind match. I tried the following but Ruby (1.8) gives > an undefined sequence error : > > $(? > Before you jump re Ruby the version I also tested this here - > http://www.rubyxp.com/ and get invalid expression (fyi this tests with > Ruby 1.9). Any ideas/alternatives? I would probably do: lines.reject {|line| line =~ /html$/ } David -- David A. Black / Ruby Power and Light, LLC Ruby/Rails consulting & training: http://www.rubypal.com Now available: The Well-Grounded Rubyist (http://manning.com/black2) Training! Intro to Ruby, with Black & Kastner, September 14-17 (More info: http://rubyurl.com/vmzN)