From: Charles Pareto Date: 2007-09-12T06:42:33+09:00 Subject: Re: Reg Ex Gavin Kistner wrote: > On Sep 6, 4:58 pm, Charles Pareto wrote: >> Does anyone know how I can modify my reg exp to not include certain >> keywords like SanFrancisco and Francisco? > > Instead of modifying the regex, how about simply working on the data > until it's right? > > ACCEPTABLE = [ /francisco/i, /scisco/i ] > matches = file.readlines.select{ |line| line =~ /[Cc]isco|CISCO/ } > ACCEPTABLE.each{ |re| matches.delete_if{ |line| line =~ re } } > puts matches If I want to print the line to a new file I use this: dnsfile.each { |line| newfile.puts line if line =~ /(\b((C|c)isco|CISCO)\b) / what can I do if I want to print it to a newfile and print it to the screen at the same time? -- Posted via http://www.ruby-forum.com/.