From: Logan Capaldo Date: 2006-02-08T04:13:50+09:00 Subject: Re: Grep via Ruby On Feb 7, 2006, at 9:30 AM, James Edward Gray II wrote: > On Feb 7, 2006, at 7:08 AM, ralf wrote: > >> I'd like to have a "grep" with case-insensitive match. > > You can turn options on/off inside a pattern. For example, here is > a pattern that matches the word file, regardless of case: > > (?i:file) > >> Maybe this can be done a lot easier by using ARGF?? > > Yes it can. Your input loop can be replaced with: > > ARGF.grep(pattern) do |line| > puts "#{ARGF.filename} #{ARGF.lineno}: #{line}" > end > > Hope that helps. > > James Edward Gray II > > Minor suggestion, line is going to end in an nl anyway. I would use print, unless you want all that extra whitespace in the output.